#include <cstdio> #include <cmath> using namespace std; bool isPerfect(int num) { if (num < 6) { return false; } int sum = 1, num_q = sqrt(num); for (int i = 2; i <= num_q; i++) { if (num % i == 0) { sum += (i + num / i); } } if (num_q * num_q == num && num_q < num) { sum -= num_q; } return sum == num; } int main() { int n, cnt; while(EOF != scanf("%d", &n)){ cnt = 0; for (int i = 1; i <= n; i++) { if (isPerfect(i)) { cnt++; } } printf("%d\n", cnt); } return 0; }