import re numbers = "0123456789" lower_case = "abcdefghijklmnopqrstuvwxyz" upper_case = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" special_characters = "!@#$%^&*()-+" has_num = False has_special = False has_upper = False has_lower = False long_enough = False def is_strong(password): global has_num global has_special global has_upper global has_lower global long_enough if len(password) >= 6: long_enough = True for char in password: if not has_lower and char in lower_case: has_lower = True if not has_upper and char in upper_case: has_upper = True if not has_special and char in special_characters: has_special = True if not has_num and char in numbers: has_num = True num_chars = input() password = input() added_char_count = 0 length = len(password) is_strong(password) # print(has_num) # print(has_special) # print(has_upper) # print(has_lower) while (not (has_num and has_special and has_lower and has_upper and long_enough)): if not has_num: added_char_count += 1 has_num = True elif not has_special: added_char_count += 1 has_special = True elif not has_upper: added_char_count += 1 has_upper = True elif not has_lower: added_char_count += 1 has_lower = True else: added_char_count += 1 long_enough = ((length + added_char_count) >= 6) print(added_char_count)