public class P1065 {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int N = Integer.parseInt(br.readLine());
int totalCnt = 0;
for(int i=1 ; i <= N ; i++){
if(isHanSu(i)) totalCnt++;
}
System.out.println(totalCnt);
}
private static boolean isHanSu(int n){
boolean result = true;
String nStr = String.valueOf(n);
int beforeDiff = 0;
int newDiff = 0;
for(int i=0 ; i < nStr.length() - 1 ; i++){
if(i == 0){
beforeDiff = Integer.parseInt(nStr.substring(i, i+1)) - Integer.parseInt(nStr.substring(i+1, i+2));
}else{
newDiff = Integer.parseInt(nStr.substring(i, i+1)) - Integer.parseInt(nStr.substring(i+1, i+2));
if(beforeDiff != newDiff){
result = false;
break;
}else{
beforeDiff = newDiff;
}
}
}
return result;
}
}