num to a string num_str.a, iterate through num_str and replace the first occurrence of a non-'9' digit with '9'.b, check if the first digit is not '1'. If it's not, replace all occurrences of the first digit with '1'. If the first digit is '1', find the next digit that is not '0' or '1' and replace all occurrences of that digit with '0'.a and b.a - b.