1 /**************************************************************
2 Problem: 2005
3 User: Doggu
4 Language: C++
5 Result: Accepted
6 Time:4 ms
7 Memory:2092 kb
8 ****************************************************************/
9
10 #include <cstdio>
11 #include <algorithm>
12 const int N = 100100;
13 int n, m, prime[N], ptot;
14 long long phi[N], ans;
15 bool vis[N];
16 void EULER(int n) {
17 phi[1]=1;
18 for( int i = 2; i <= n; i++ ) {
19 if(!vis[i]) prime[++ptot]=i, phi[i]=i-1;
20 for( int j = 1; j <= ptot; j++ ) {
21 if((long long)i*prime[j]>n) break;
22 vis[i*prime[j]]=1;
23 phi[i*prime[j]]=phi[i]*(prime[j]-1);
24 if(i%prime[j]==0) {
25 phi[i*prime[j]]=phi[i]*prime[j];
26 break;
27 }
28 }
29 phi[i]+=phi[i-1];
30 }
31 }
32 int main() {
33 scanf("%d%d",&n,&m);
34 if(n>m) std::swap(n,m);
35 EULER(n);
36 for( int a = 1, ed; a <= n; a=ed+1 ) {
37 ed=std::min(n/(n/a),m/(m/a));
38 ans+=(long long)(phi[ed]-phi[a-1])*(n/a)*(m/a);
39 }
40 printf("%lld\n",ans*2-(long long)n*m);
41 return 0;
42 }