num=int(input()) count=0 i=0 while i<=num: i1=i**2 i2=str(i1) if i2.endswith(str(i)): # endswith:代表以什么结尾 count=count+1 i=i+1 print(count)