import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
while (sc.hasNext()) {
int number = sc.nextInt();
// 统计完全因子的个数
int count = 0;
while (number > 2) {
int sum = 1;
for (int i = 2; i < number / 2 + 1; i++) {
if (number % i == 0) {
sum += i;
}
}
if (sum == number) {
count++;
}
number--;
}
System.out.println(count);
}
}
}