use std::io::*; fn main() { let mut s: String = String::new(); std::io::stdin().read_to_string(&mut s).ok(); let mut itr = s.trim().split_whitespace(); let n: u64 = itr.next().unwrap().parse().unwrap(); let mut q: std::collections::VecDeque = (1..10).collect(); let mut ans = 0; while let Some(x) = q.pop_front() { if x * 1000000001 > n { println!("{}", ans); return; } ans += 1; q.push_back(x * 10 + x); } }