------
## 最终结论
```python
def max_difference(num):
    # Convert the number to a string to manipulate its digits
    num_str = str(num)
    
    # Find the maximum digit that is not '9' and create a
    for digit in num_str:
        if digit != '9':
            a = int(num_str.replace(digit, '9'))
            break
    else:
        a = num  # If all digits are '9', no change is needed
    
    # Find the first non-'1' digit for b (to avoid leading zero)
    if num_str[0] != '1':
        b = int(num_str.replace(num_str[0], '1'))
    else:
        for digit in num_str[1:]:
            if digit != '0' and digit != '1':
                b = int(num_str.replace(digit, '0'))
                break
        else:
            b = num  # If no valid replacement found
    
    # Calculate and return the maximum difference
    return a - b

# Example usage:
print(max_difference(555))   # Output: 888
print(max_difference(9))     # Output: 8
print(max_difference(123456))# Output: 820000
print(max_difference(10000)) # Output: 80000
print(max_difference(9288))  # Output: 8700
```