#include "bits/stdc++.h"
using namespace std;
struct pair_hash {
size_t operator()(const pair<int, int> &p) const {
return p.first ^ p.second;
}
};
int fff(int n, int m) {
return mt19937_64((1ll * n) << 25 | m)() % 1e8;
}
unordered_map<int, int> saved_mx;
int mx_func(int n, int m) {
if (n > m) {
swap(n, m);
}
if (saved_mx.contains(fff(n, m))) {
return saved_mx[fff(n, m)];
}
int cur = 0;
if (n % 2 == 0 && m - n / 2 > 0) {
cur = max(cur, mx_func(n, m - n / 2));
}
if (m % 2 == 0 && n - m / 2 > 0) {
cur = max(cur, mx_func(n - m / 2, m));
}
if (m - 2 * n > 0) {
cur = max(cur, mx_func(n, m - 2 * n));
}
if (n - 2 * m > 0) {
cur = max(cur, mx_func(n - 2 * m, m));
}
return saved_mx[fff(n, m)] = cur + 1;
}
unordered_map<int, int> saved_mn;
int mn_func(int n, int m) {
if (n > m) {
swap(n, m);
}
if (saved_mn.contains(fff(n, m))) {
return saved_mn[fff(n, m)];
}
if (n == 2 * m || m == 2 * n) {
return 1;
}
int cur = INT32_MAX;
if (n % 2 == 0 && m - n / 2 > 0) {
cur = min(cur, mn_func(n, m - n / 2));
}
if (m % 2 == 0 && n - m / 2 > 0) {
cur = min(cur, mn_func(n - m / 2, m));
}
if (m - 2 * n > 0) {
cur = min(cur, mn_func(n, m - 2 * n));
}
if (n - 2 * m > 0) {
cur = min(cur, mn_func(n - 2 * m, m));
}
return saved_mn[fff(n, m)] = cur + 1;
}
signed main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
saved_mn.reserve(1e8);
saved_mx.reserve(1e8);
int n, m;
cin >> n >> m;
cout << mn_func(n, m) << ' ' << mx_func(n, m) << '\n';
return 0;
}