import java.math.BigInteger; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.Comparator; import java.util.HashMap; import java.util.HashSet; import java.util.LinkedList; import java.util.Scanner; import java.util.Set; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); final long n = sc.nextLong(); long count = 0; long curr = 1000000001; long base = curr; while(curr <= n){ for(int i = 0; i < 9; i++){ if(curr > n){ break; } count++; curr += base; } curr += base; //System.out.println(curr + " " + count); base = curr; } System.out.println(count); } }