1 #include<iostream>
2 #include<cstdio>
3 #include<cstdlib>
4 using namespace std;
5
6 typedef long long ll;
7 #define maxn 100010
8 int n,m,tot,prime[maxn],mu[maxn];
9 bool exist[maxn]; ll ans;
10
11 inline void find()
12 {
13 mu[1] = 1;
14 for (int i = 2;i <= n;++i)
15 {
16 if (!exist[i]) prime[++tot] = i,mu[i] = -1;
17 for (int j = 1;j <= tot&&i*prime[j]<=n;++j)
18 {
19 exist[i*prime[j]] = true;
20 if (i % prime[j] == 0) { mu[i*prime[j]] = 0; break; }
21 mu[i*prime[j]] = -mu[i];
22 }
23 }
24 for (int i = 1;i <= n;++i) mu[i] += mu[i-1];
25 }
26
27 inline ll calc(int a,int b,int d)
28 {
29 a /= d; b /= d;
30 ll ret = 0; int pos;
31 for (int i = 1;i <= a;i = pos+1)
32 {
33 pos = min(a/(a/i),b/(b/i));
34 ret += (ll)(mu[pos]-mu[i-1])*(ll)(a/i)*(ll)(b/i);
35 }
36 return ret;
37 }
38
39 int main()
40 {
41 freopen("2005.in","r",stdin);
42 freopen("2005.out","w",stdout);
43 scanf("%d %d",&n,&m); if (n > m) swap(n,m);
44 find();
45 for (int i = 1;i <= n;++i)
46 ans += (ll)((i<<1)-1)*calc(n,m,i);
47 printf("%lld",ans);
48 fclose(stdin); fclose(stdout);
49 return 0;
50 }