// $Id: hash.csharp,v 1.0 2002/02/14 14:48:00 dada Exp $
// http://dada.perl.it/shootout/

using System;
using System.Collections;

class App {
    public static int Main(String[] args) {        
        int n;
        Hashtable X = new Hashtable();     
        int c = 0;
        
        n = System.Convert.ToInt32(args[0]);
        if(n < 1) n = 1;
        
        for(int i=1; i<=n; i++) {
            X.Add( i.ToString("x"), i);
        }
        
        for(int i=n; i>0; i--) {
            if(X.ContainsKey(i.ToString())) c++;
        }
        Console.WriteLine(c.ToString());
        return(0);
    }
}