public class Main {
public static void main(String[] args) {
int ans =0;
int temp =0;
for (int i = 1; i < 2021; i++) {
temp =i;
while (temp>=1){
if (temp%10==2){
ans +=1;
}
temp /= 10;
}
}
System.out.println(ans);//624
}
}