#include<iostream>
#include<cstdio>
using namespace std;
const int N=2005;
int n,m,l,r;
long long ans;
int g[N][N];
int gcd(int a,int b)
{
int t;
while(b) t=a%b,a=b,b=t;
return a;
}
int main()
{
freopen("rockboard.in","r",stdin);
freopen("rockboard.out","w",stdout);
scanf("%d%d%d%d",&n,&m,&l,&r);
int k=max(n,m);
for(int i=1;i<=k;++i)
for(int j=i;j<=k;++j)
g[i][j]=g[j][i]=gcd(i,j);
for(int i=1;i<=n;++i)
for(int j=1;j<=m;++j)
if(i*i+j*j>l*l&&i*i+j*j<r*r&&g[i][j]==1)
ans+=(n-i+1)*(m-j+1);
ans*=2;
printf("%lld\n",ans);
return 0;
}