import java.util.*; public class Main{ public static void main(String[] args){ Scanner sc = new Scanner(System.in); int N = sc.nextInt(); int r = 0; for(int i = 1; i <= N; ++i) r += f(i); System.out.println(r); } public static int f(int n){ String[] v = {"0", "1", "5", "", "", "2", "9", "", "8", "6"}; String N = String.valueOf(n);//把原数字当成字符串处理,避免除法和取余 StringBuilder sb = new StringBuilder(); for(int i = 0; i < N.length(); ++i) sb.append(v[N.charAt(i) - '0']); if(sb.length() != N.length()) return 0;//变短了,肯定有347 if(Integer.valueOf(String.valueOf(sb)) != n) return 1; return 0; } }