// Source: https://usaco.guide/general/io
#include <bits/stdc++.h>
using namespace std;
bool valid(int x, int y){
if(x/y==0)return valid(y,x);
if(y<1||x<2*y)return false;
if(y==1)return (x%2==0);
return valid(x%(2*y),y);
}
int main() {
//find all perfect fractions less than 1/2 and place them into
// an array then propogate numerator and denominator to their limits
int n,m,ans=0;
cin >> n >> m;
vector<pair<int,int>> perf;
for (int i =1;i<=n;i++){
for(int j=1;j<=m;j++){
if(gcd(i,j)!=1)continue;
if(valid(i,j))ans++;
}
}
cout << ans << "\n";
}