import sys import datetime def date_range(start: datetime.date, end: datetime.date) -> datetime.date: one_day = datetime.timedelta(days=1) d = start while d <= end: yield d d += one_day def is_happy_day(d: datetime.date) -> bool: x = d.month y = 0 day = d.day while day > 0: day, z = divmod(day, 10) y += z return x == y def resolve(in_): start = datetime.datetime(2015, 1, 1) end = datetime.datetime(2015, 12, 31) ans = sum(1 for _ in filter(is_happy_day, date_range(start, end))) return ans def main(): ans = resolve(sys.stdin.buffer) print(ans) if __name__ == '__main__': main()