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