import java.util.Scanner; public class Kaibun { public static void main(String[] args) throws InterruptedException { Scanner s = new Scanner(System.in); long t = (long)Math.pow(10, 9) +1 , N = s.nextLong(); s.close(); int end = (int)(N/t); long count = 0, stock = 0; int keta = Integer.toString(end).length(); if(keta == 1){ count = end; }else{ stock = 9; for(int i = 1;i < keta;i++){ count += stock; if(i%2 == 0){ stock *= 10; } } int k = (int)Math.pow(10, keta/2); count += ((end - (int)Math.pow(10,keta-1))/k+1); StringBuilder str = new StringBuilder(Integer.toString(end/k)); String str2 = str.toString(); if(keta%2 == 1){ str.deleteCharAt(str.length()-1); } str2 = str2.concat(str.reverse().toString()); if(Integer.parseInt(str2) > end){ count--; } } System.out.println(count); } }