#include "bits/stdc++.h"
using i64 = long long;
int n, m, l, r;
int gcd(int a, int b) {
return b ? gcd(b, a % b) : a;
}
int main() {
freopen("rockboard.in", "r", stdin);
freopen("rockboard.out", "w", stdout);
std::cin >> n >> m >> l >> r, l *= l, r *= r;
i64 res = 0;
for (int i = 0; i <= n; ++ i)
for (int j = 0; j <= m; ++ j) {
int x = i * i + j * j;
if ((i || j) && gcd(i, j) == 1 && x >= l && x <= r) {
res += 2 * (n - i + 1) * (m - j + 1);
if (i + j == 1) {
res -= (n - i + 1) * (m - j + 1);
}
}
}
std::cout << res << '\n';
return 0;
}