#include <cstdio>
#include <cstdlib>
using namespace std;
bool huzhi (int a, int b)
{
while (b)
{
int t = b;
b = a%b;
a = t;
}
return a==1;
}
int main ()
{
freopen("banner.in", "r", stdin);
freopen("banner.out", "w", stdout);
long long W, H, L1, L2;
scanf("%lld%lld%lld%lld", &W, &H, &L1, &L2);
long long ans = 0;
for (int i=0; i<=W; i++)
for (int j=0; j<=H; j++)
{
if (L1 == 1)
{
if (i-1 >= 0)
ans++;
if (j-1 >= 0)
ans++;
if (i < W)
ans++;
if (j < H)
ans++;
}
for (int ii=1; ii<L2; ii++)
for (int jj=1; jj<L2; jj++)
if (huzhi(ii, jj))
{
long long tmp = ii*ii + jj*jj;
if (tmp < L1*L1)
continue;
if (tmp > L2*L2)
break;
if (i-ii >= 0)
{
if (j-jj >= 0)
ans++;
if (j+jj <= H)
ans++;
}
if (i+ii <= W)
{
if (j-jj >= 0)
ans++;
if (j+jj <= H)
ans++;
}
}
}
printf("%lld\n", ans/2);
return 0;
}