#include <fstream>
#include <iostream>
#include <algorithm>
int ucln(int a, int b)
{
    while (b > 0)
    {
        int r = a%b;
        a = b;
        b = r;
    }
    return a;
}
using namespace std;
int x[1000000]; int y[1000000];
int main()
{
   ifstream f1("bai1_13.inp");
   ofstream f2("bai1_13.out");
   int d = 2,n,k;
   x[1] = 0; y[1] = 1;
   f1 >> n >> k;
   for (int i = 1; i < n; i++)
   {
       for (int j = i+1; j <= n; j++)
       {
           if (ucln(i,j) == 1)
           {
               x[d] = i; y[d] = j;
               d++;
           }
       }
   }
   x[d] = 1; y[d] = 1;
   for (int i = 1; i < d-1; i++)
   {
       for (int j = i+1; j <= d-1; j++)
       {
           if (float(x[i])/float(y[i]) > float(x[j])/float(y[j]))
           {
               int tg = x[i]; x[i] = x[j]; x[j] = tg;
               tg = y[i]; y[i] = y[j]; y[j] = tg;
           }
       }
   }
   f2<<d<<endl;
   f2<< x[k] << " "<< y[k];
   return 0;
}
