/* 29 . 03 . 2008 */
#include <bits/stdc++.h>
using namespace std ;
bool watbor = 1;
#define int long long
typedef long long ll ;
typedef vector<int> vi ;
typedef vector<pair<int,int>> vii ;
typedef pair<int,int> pii ;
typedef pair<ll,int> pli ;
typedef pair<int,ll> pil ;
typedef pair<ll,ll> pll ;
#define FOR(i,a,b) for(int i(a) ; i <= (int)b ; i++)
#define FORD(i,a,b) for(int i(a) ; i >= (int)b ; i--)
#define FORN(i,a,b) for(int i(a) ; i < (int)b ; i++)
#define all(a) a.begin() , a.end()
#define pb push_back
#define fi first
#define se second
#define endl '\n'
#define BIT(mask,i) ((mask>>i)&1)
#define builtin_popcount builtin_popcountll
#define uni(a) sort(all(a)), a.resize(unique(all(a))-a.begin())
#define MASK(a) (1ll << a)
int gcd(int x, int y) {return __gcd(x, y) ;}
int lg(int x) {return __lg(x) ;}
int lcm(int x, int y) {return x / __gcd(x, y) * y ;}
template <class T> bool maxi(T &x,T y) { if (x < y) { x = y ; return true ;} return false ;}
template <class T> bool mini(T &x,T y) { if (x > y) { x = y ; return true ;} return false ;}
const int N = 2e5 + 5, M = 5e3 + 5, LG = __lg(N) + 1, base = 311 ;
const int oo = 2e9, sm = 1e9 + 7, mod1 = 1e9 + 7, mod2 = 998244353 ;
const long long inf = 1e18 ;
int n, m;
void init(){
cin >> n >> m;
}
int isFS[N + 5], preFS[N + 5];
int checkFS(int x){
int chanle = 0;
for (int i = 2; 1ll * i * i <= x; i++) if(x % i == 0){
int cnt = 0;
chanle++;
while(x % i == 0){
cnt++;
x /= i;
}
if(cnt > 1) return 0 ;
}
if(n != 1)
chanle++;
if(chanle % 2 == 0) return -1;
return 1;
}
void buildFreeSquare(){
FOR(i, 2, N)
isFS[i] = checkFS(i);
FOR(i, 1, N)
preFS[i] = preFS[i - 1] + isFS[i];
}
void solve(){
ll ans = 0;
for(int i = 1; i <= n;){
int u = n / i, v = m / i;
int j = 2e9;
if(u != 0) j = min(j, n / u);
if(v != 0) j = min(j, m / v);
ans+= (n / i) * (m / i) * (preFS[j] - preFS[i - 1]);
i = j + 1;
}
cout << m * n - ans << "\n";
}
signed main(){
ios_base::sync_with_stdio(0) ; cin.tie(0) ; cout.tie(0) ;
#define task "cpcnt"
if(fopen(task".inp","r")){
freopen(task".inp","r",stdin) ;
freopen(task".out","w",stdout) ;
}
int tc ; tc = 1 ;
if(watbor) cin >> tc ;
buildFreeSquare();
FOR(bqc, 1, tc) {
init() ;
solve() ;
}
cerr << "\nTime : " << clock() * 0.001 << "s" << endl ;
return 0 ;
}
/* Watbor */
LyogMjkgLiAwMyAuIDIwMDggKi8gCiNpbmNsdWRlIDxiaXRzL3N0ZGMrKy5oPgp1c2luZyBuYW1lc3BhY2Ugc3RkIDsKCmJvb2wgd2F0Ym9yID0gMTsKCiNkZWZpbmUgaW50IGxvbmcgbG9uZwp0eXBlZGVmIGxvbmcgbG9uZyBsbCA7CnR5cGVkZWYgdmVjdG9yPGludD4gdmkgOwp0eXBlZGVmIHZlY3RvcjxwYWlyPGludCxpbnQ+PiB2aWkgOwp0eXBlZGVmIHBhaXI8aW50LGludD4gcGlpIDsKdHlwZWRlZiBwYWlyPGxsLGludD4gcGxpIDsKdHlwZWRlZiBwYWlyPGludCxsbD4gcGlsIDsKdHlwZWRlZiBwYWlyPGxsLGxsPiBwbGwgOwoKI2RlZmluZSBGT1IoaSxhLGIpIGZvcihpbnQgaShhKSA7IGkgPD0gKGludCliIDsgaSsrKQojZGVmaW5lIEZPUkQoaSxhLGIpIGZvcihpbnQgaShhKSA7IGkgPj0gKGludCliIDsgaS0tKQojZGVmaW5lIEZPUk4oaSxhLGIpIGZvcihpbnQgaShhKSA7IGkgPCAoaW50KWIgOyBpKyspCiNkZWZpbmUgYWxsKGEpIGEuYmVnaW4oKSAsIGEuZW5kKCkKI2RlZmluZSBwYiBwdXNoX2JhY2sKI2RlZmluZSBmaSBmaXJzdAojZGVmaW5lIHNlIHNlY29uZAojZGVmaW5lIGVuZGwgJ1xuJyAKI2RlZmluZSBC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