#include<bits/stdc++.h>
using namespace std;
#define int long long
int n, m, l, r, ans, mod;
signed main() {
freopen("rockboard.in", "r", stdin);
freopen("rockboard.out", "w", stdout);
cin >> n >> m >> l >> r;
for(int i = 0; i <= n; i ++) {
for(int j = 0; j <= m; j ++) {
if(i == 0 && j == 0) {
continue;
}
int x = i * i + j * j;
if(x < l * l || x > r * r) {
continue;
}
if(__gcd(i, j) != 1) {
continue;
}
// cout << i << ' ' << j << endl;
ans += (n - i + 1) * (m - j + 1);
if(i + j != 1) {
ans += (n - i + 1) * (m - j + 1);
}
// ans %= mod;
}
}
cout << ans;
return 0;
}