#include <iostream>
#include <cstdio>
#define LL long long
LL n, m, ans, f[1000005];
int main()
{
FILE *fi, *fo;
fi = fopen("energy2010.in", "r");
fscanf(fi, "%lld%lld", &n, &m);
if (n < m)
std::swap(n, m);
for (int i = m; i; --i)
{
f[i] = (n / i) * (m / i);
for (int j = 2; i * j <= m; ++j)
f[i] -= f[i * j];
ans += f[i] * i;
}
fo = fopen("energy2010.out", "w");
fprintf(fo, "%lld\n", ans * 2 - n * m);
fclose(fo);
return 0;
}