print(sum(v * (100 <= v <= 999 and v % 4 == 0) for v in map(int, iter(input, '0'))))
print(sum(int(input()) % 30 == 24 for _ in range(int(input()))))
print(sum(10 <= v <= 99 and v % 8 == 0 for v in map(int, iter(input, '0'))))