def can_convert_to_same(D): # Count the number of '0's and '1's count_0 = D.count('0') count_1 = D.count('1') # Check if there is exactly one '0' or one '1' if count_0 == 1 or count_1 == 1: return "YES" else: return "NO" # Input: Read the binary number from the user D = input("Enter the binary number: ").strip() # Output: Print 'YES' or 'NO' depending on the condition print(can_convert_to_same(D))