N=gets.to_i/(10**9+1)
ans=0
1.upto(10**5-1){|i|
	t=(i.to_s+i.to_s.reverse).to_i
	ans+=1 if t<=N
	t=(i.to_s[0..-2]+i.to_s.reverse).to_i
	ans+=1 if t<=N
}
p ans