//最简单的hash
#include<iostream>
using namespace std;
int a, b, c, d;
int x1, x2, x3, x4;
int f1[1000005];
int f2[1000005];
int main()
{
while(cin >> a >> b >> c >> d)
{
if( a > 0 && b > 0 && c > 0 && d > 0){
cout<<0<<endl;
continue;
}
if( a < 0 && b < 0 && c < 0 && d < 0){
cout<<0<<endl;
continue;
}
for(int i = 0; i < 1000005; i ++) f1[i] = 0;
for(int j = 0; j < 1000005; j ++) f2[j] = 0;
int ans = 0;
int s;
for(int i = 1; i <= 100; i ++)
{
x1 = i;
for(int j = 1; j <= 100; j ++)
{
x2 = j;
s = a * x1 * x1 + b * x2 * x2;
if(s >= 0) f1[s] ++; // s等于0的给f1
else f2[-s] ++;
}
}
for(int i = 1; i <= 100; i ++)
{
x3 = i;
for(int j = 1; j <= 100; j ++)
{
x4 = j;
s = c * x3 * x3 + d * x4 * x4;
if(s > 0) ans += f2[s]; // 所以这边是s>0而不是s>=0了
else ans += f1[-s];
}
}
cout<<ans*16<<endl;
}
return 0;
}