s = input() dic = {} # Initialize a dictionary to count the occurrence of the letters. for char in s: if char not in dic: dic[char] = 1 else: dic[char] += 1 lowest_occur = min(dic.values()) str_rem = '' # Use an empty string to store letters to remove for key, value in dic.items(): # Use the .items() method to iterate over the key-value pairs. if value == lowest_occur: str_rem += key for char in str_rem: s = s.replace(char, "") # Use the .replace() method to remove the specified characters in str_rem. print(s)