bool judge(int x) { int num=0; while(x) { if (x % 10 == 3 || x % 10 == 4 || x % 10 == 7) return false; else if (x % 10 == 2 || x % 10 == 5 || x % 10 == 6 || x % 10 == 9) num++; x /=10; } return (num)? true : false; } int rotatedDigits(int N){ int count=0; for (int i=1; i<=N; i++) { if (judge(i)) count++; } return count; }