import math
w = int(input())
b= []
for i in range(w+1):
a = str(pow(i, 2))[::-1]
if str(i)[::-1] == a[:len(str(i))]:
b.append(i)
print(len(b))
w = int(input())
b= []
for i in range(w+1):
a = str(pow(i, 2))[::-1]
if str(i)[::-1] == a[:len(str(i))]:
b.append(i)
print(len(b))