public class Main {
public static void main(String[] args) {
int n = 0;
for(int i = 1; i <= 2019; i++) {
if(i % 10 == 9 || i / 10 % 10 == 9 || i / 100 % 10 == 9) {
n++;
}
}
System.out.println(n);
}
}