package backjoon; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; // https://www.acmicpc.net/problem/1065 // íì // íì리ìì íì ê°ì: 9 (1~9) // ëì리ìì íì ê°ì: 99 (1~99) // ì를 ë¤ì´, 110ì íì ê°ì: 99 (1~99) // ì를 ë¤ì´, 111ì íì ê°ì: 100 (1~99 + 111 = ì´ 100ê°) public class _1065 { public static void main(String[] args) throws IOException { //memory 11496 run 84 BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int n = Integer.parseInt(br.readLine()); int cnt; if(n < 100 ){ System.out.println(n); }else{ cnt = 99; for(int i=100; i<=n; i++){ int hundreds = i / 100 % 10; int tens = i / 10 % 10; int units = i % 10; // ë±ì°¨ìì´ì¸ì§ íì¸í기 if ((hundreds - tens) == (tens - units)) { cnt++; } } // ì£ì§ì¼ì´ì¤ if (n == 1000){ cnt--; } System.out.println(cnt); } } } /* input 110 1 210 output 99 1 105 */