#include <iostream>
#include <cstdio>
using namespace std;

int m,n,rez;

int main() {
  //freopen("tst.in","r",stdin);
  //freopen("ou","w",stdout);
  while(cin>>m>>n) {
    for(int i=0; i<=m; ++i) for(int j=i; j<=m; ++j) for(int k=j; k<=m; ++k)
      if(i*i+j*j==k*k)
        rez++;
    rez+=(n-2)*(m+1);
    cout<<rez<<'\n';
    rez=0;
  }
}