/* The Great Win32 Language Shootout http://dada.perl.it/shootout/ 
   contributed by Isaac Gouy (Nice novice)

To compile:	
   nicec --sourcepath=.. -d=. -a hash.jar hash

To run:
   java -jar hash.jar 80000
*/


import ackermann; // reuse toSingleInt


void main(String[] args){
   let n = toSingleInt(args);
   var count = 0;

   HashMap table = new HashMap();

   for (int i = 1; i <= n; i++) 
      table.put( toString(i, 16), i );
   for (int i = n; i > 0; i--)
      if (table.get( toString(i, 10) ) != null) count++;

   println(count);
}


String toString(int, int) = 
   native String java.lang.Integer.toString(int, int);