from collections import Counter S = list(txt_input[0]) S_unique = list(set(S)) if len(S) - len(S_unique) == 6: dct = Counter(S) search_letter = 1 for letter, age in dct.items(): if age == search_letter: print(letter) else: print(Impossible)