#include #include #include using namespace std; int l, r; bool check[1000000 + 5] = {}; int cal(int x) { int j,t = -x,t2; for (j = 1; j * j <= x ; j++) { if (x % j == 0) { t = t + j + x / j; } if (t > r) return 0; } t2 = (int) sqrt(x); if (sqrt(x) == t2) { t = t - t2; } return t; } int main() { #ifndef ONLINE_JUDGE freopen ("input.txt", "r", stdin); freopen ("output.txt", "w", stdout); #endif ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n, i, temp,dem = 0; cin >> l >> r; for (i = l; i <= r; i++) { if (check[i] == 0) { temp = cal(i); if ((temp > r) || (temp < l)) { continue; } else { if (cal(temp) == i) { dem++; check[i] = 1; check[temp] = 1; } } } } cout << dem; return 0; }