1 #include <iostream>
2 #include <cstdio>
3 #include <cstring>
4 #include <cstdlib>
5 #define min(a, b) ((a) < (b) ? (a) : (b))
6
7 inline void read(long long &x)
8 {
9 x = 0;char ch = getchar(), c = ch;
10 while(ch < ‘0‘ || ch > ‘9‘)c = ch, ch = getchar();
11 while(ch <= ‘9‘ && ch >= ‘0‘)x = x * 10 + ch - ‘0‘, ch = getchar();
12 if(c == ‘-‘)x = -x;
13 }
14
15 const long long MAXN = 100000 + 10;
16
17 long long f[MAXN << 1], n, m, ans, mi, phi[MAXN], bprime[MAXN], prime[MAXN], tot;
18
19 void make_phi()
20 {
21 phi[1] = 1;
22 for(register long long i = 2;i <= mi;++ i)
23 {
24 if(!bprime[i])
25 {
26 prime[++tot] = i;
27 phi[i] = i - 1;
28 }
29 for(register long long j = 1;j <= tot && i * prime[j] <= mi;++ j)
30 {
31 bprime[i * prime[j]] = 1;
32 if(i % prime[j] == 0)
33 {
34 phi[i * prime[j]] = phi[i] * prime[j];
35 break;
36 }
37 phi[i * prime[j]] = phi[i] * (prime[j] - 1);
38 }
39 }
40 for(register long long i = 1;i <= mi;++ i) phi[i] += phi[i - 1];
41 }
42
43 int main()
44 {
45 read(n), read(m);
46 mi = min(n, m);
47 make_phi();
48 register long long x,y,last;
49 for(register long long d = 1;d <= mi;++ d)
50 {
51 x = n/d, y = m/d;
52 last = min(n/x, min(m/y, mi));
53 ans += (phi[last] - phi[d - 1]) * x * y;
54 d = last;
55 }
56 printf("%lld", 2 * ans - n * m);
57 return 0;
58 }