#include "bits/stdc++.h"
using namespace std;
struct pair_hash {
size_t operator()(const pair<int, int> &p) const {
return p.first ^ p.second;
}
};
static constexpr int maxn = 200000131;
int fff(int n, int m) {
return ((1ll * n) << 26 | m) % maxn;
}
int saved_mx[maxn];
int mx_func(int n, int m) {
if (n > m) {
swap(n, m);
}
if (saved_mx[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;
}
int saved_mn[maxn];
int mn_func(int n, int m) {
if (n > m) {
swap(n, m);
}
if (saved_mn[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);
int n, m;
cin >> n >> m;
cout << mn_func(n, m) << ' ' << mx_func(n, m) << '\n';
return 0;
}