M, D = map(int, input().split(' ')) B = 822 BB = M*100 + D ans = 2024-2000 - 1 + (1 if BB >= B else 0) print(ans)