#include<bits/stdc++.h>
using namespace std;
long long n, m;
long long fib[100];
long long calc(long long a, long long b) {
if (a == b) return a;
if (a < b) swap(a, b);
return calc(b, a - b);
}
long long check(long long x, long long y) {
fib[0] = 1;
fib[1] = 1;
for(int i = 2; i < 75; i++) fib[i] = fib[i - 1] + fib[i - 2];
long long res = 0;
for(int i = 1; i < 70; i++) {
if (x * fib[i] % fib[i + 1] == 0) {
long long z = x * fib[i] / fib[i + 1];
res = max(res, (x - calc(x, z)) * y);
}
}
return res;
}
int main()
{
scanf("%lld%lld", &n, &m);
printf("%lld\n", max(check(n, m), check(m, n)));
}