/*
TASK: rtri
LANG:C++
*/

#include <iostream>
#include <map>
#include <set>
#include <math.h>
using namespace std;

map< set<pair<int,int> >,bool > used;
set< pair<int,int> > s;
unsigned N,M,All=0;
pair<int,int> p1,p2,p3,ratio,temp1,temp2,temp1r,temp2r;


int GCD(int a,int b)
{
int t;
    while(b!=0)
    {
       t=a%b;
       a=b;
       b=t;
    }
    return a;
}

void Read()
{
     cin>>M>>N;
     N++;
     M++;
}

pair<int,int> Make(pair<int,int> pf, pair<int,int> ps)
{
int gcd;
pair<int,int> temp;

     temp.first=abs(pf.first-ps.first);
     temp.second=abs(pf.second-ps.second);
                           
     gcd=GCD(temp.first,temp.second);
     temp.first/=gcd;
     temp.second/=gcd;
     
     return temp;
}

void FindSolution()
{     
     for(int i1=1;i1<=M;i1++)
        for(int j1=1;j1<=N;j1++)
        {
             p1.first=i1; p1.second=j1;
             
             for(int i2=1;i2<=M;i2++)
                for(int j2=1;j2<=N;j2++)
                if(i1!=i2 || j1!=j2)
                {
                    p2.first=i2; p2.second=j2;
                    
                    ratio=Make(p1,p2);
                    
                    for(int i3=1;i3<=M;i3++)
                       for(int j3=1;j3<=N;j3++)
                       if( (i3!=i1 || j3!=j1) && (i3!=i2 || j3!=j2) )
                       {
                           p3.first=i3; p3.second=j3;
                           
                           temp1=Make(p1,p3);
                           temp1r.first=temp1.second;
                           temp1r.second=temp1.first;
                           
                           temp2=Make(p2,p3); 
                           temp2r.first=temp2.second;
                           temp2r.second=temp2.first;
                           
                           if( (temp1==ratio||temp1r==ratio||temp2==ratio||temp2r==ratio) )
                           if( ((p1.first!=p2.first)||(p1.first!=p3.first)) && 
                               ((p1.second!=p2.second)||(p1.second!=p3.second))  )
                           {
                                s.insert(p1); s.insert(p2); s.insert(p3);
                                if(!used[s])
                                {
                                     used[s]=true;
                    //                 cout<<p1.first<<" "<<p1.second<<"   "<<p2.first<<" "<<p2.second<<"   "<<p3.first<<" "<<p3.second<<endl;
                                     All++;
                                }
                                s.clear();
                           }
                       }
                }
        }
}

void Write()
{
     cout<<All<<"\n";
     
//     system("pause");
}

int main()
{
    Read();
    
    FindSolution();
    
    Write();
    
    return 0;
}
