def dcf(x): a = [] while x > 0: s = x % 10 x //= 10 a.insert(0, s) return a n = int(input()) l = [] s = 0 c = 0 for i in range(10, n + 1): l = dcf(i) s = len(l) if s == 2 and l[0] == l[1]: c += 1 elif s == 3 and l[0] == l[2]: c += 1 elif s == 4 and l[0] == l[3] and l[1] == l[2]: c += 1 print(c + 9) /************************************************************** Problem: 1149 User: admin Language: Python Result: Accepted Time:191 ms Memory:34480 kb ****************************************************************/