n = int(input())

count = 0

for i in range(1, n + 1):
    s = str(i)
    for x in s:
        if x == '3' or x == '6' or x == '9':
            count += 1

print(count)

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: