구현 (113)
n = int(input())
if (n <= 2):
cnt = ( (45*15)+(15*60) ) * (n+1)
elif (n <= 12):
cnt = 3600 + ( (45*15)+(15*60) ) * n
elif (n <= 22):
cnt = 7200 + ( (45*15)+(15*60) ) * n
else:
cnt = 10800 + ( (45*15)+(15*60) ) * n
print(cnt)
n = int(input())
cnt = 0
for i in range(n+1):
for j in range(60):
for k in range(60):
if ( '3' in str(i) + str(j) + str(k) ):
cnt += 1
print(cnt)