public class Solution { public int RotatedDigits(int N) { int sum = 0; for (int i = 1; i <= N; i++) { var str = i.ToString(); if ((str.Contains("2") || str.Contains("5") || str.Contains("6") || str.Contains("9")) && !str.Contains("3") && !str.Contains("4") && !str.Contains("7")) { sum++; } } return sum; } }