import java.util.*; import java.io.*; public class Main { public static Scanner sc = new Scanner(System.in); public static PrintWriter pw = new PrintWriter(System.out); public static void main(String[] args) { int t = 1; while( t > 0 ) { solve(); t--; } pw.flush(); } static void solve() { long N = sc.nextLong(); long ans = 0; for( long d = 1; d <= 100000; d++,ans++ ) { long ttv = Long.valueOf(Long.toString(d)+Long.toString(d)+Long.toString(d)); if( ttv > N ) break; } pw.println(ans); } }