import re
import sys
expr = re.compile(r'([0-9]239)|(2[023]39)|(23[039]9)|(239[0-9])')
inf = sys.stdin
h, m = map(int,inf.readline().split())
print(sum(1 for i in range(h) for j in range(m) if expr.fullmatch(f'{i:02d}{j:02d}')))