n = int(input())
c = 0
for i in range(1, n + 1):
q = i // 1000 % 10
b = i // 100 % 10
s = i // 10 % 10
g = i // 1 % 10
s = q + b + s + g
if s % 2 != 0 and s % 5 != 0:
c += 1
print(c)
/**************************************************************
Problem: 1395
User: admin
Language: Python
Result: Accepted
Time:197 ms
Memory:34480 kb
****************************************************************/