#include <iostream>
#include <cstring>
using namespace std;
#define maxn 25000005
short int hash[maxn];
int main()
{
int a,b,c,d,e;
while(cin>>a>>b>>c>>d>>e)
{
memset(hash,0,sizeof(hash));
int i1,i2,i3,i4,i5;
int sum=0;
for(i1=-50;i1<=50;i1++)
if(i1)
for(i2=-50;i2<=50;i2++)
if(i2)
{
sum=a*i1*i1*i1+b*i2*i2*i2;
if(sum<0)
sum=sum+maxn;
hash[sum]++;
}
int num=0;
for(i3=-50;i3<=50;i3++)
if(i3)
for(i4=-50;i4<=50;i4++)
if(i4)
for(i5=-50;i5<=50;i5++)
if(i5)
{
sum=c*i3*i3*i3+d*i4*i4*i4+e*i5*i5*i5;
sum=-sum;
if(sum<0)
sum=sum+maxn;
if(hash[sum]!=0)
num=num+hash[sum];
}
cout<<num<<endl;
}
return 0;
}