#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 >> r >> l;
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] < r || dis[i][j] > l)
dis[i][j] = 0;
}
}
}
if (r <= 1 && l >= 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 * m * 2 - (i - 1) * m * 2 - (j - 1) * n * 2;
}
}
}
cout << ans << endl;
return 0;
}