#include #include #include #include #include #include #include int getLength(char* password) { int i = 0; while (*(password + i) != '\0') { i++; } return i; } bool hasDigit(char* password) { bool result = false; int i = 0; while (*(password + i) != '\0') { if ((int)*(password + i) >= 48 && (int)*(password + i) <= 57) { result = true; break; } i++; } return result; } bool hasUpperCase(char* password) { bool result = false; int i = 0; while (*(password + i) != '\0') { if ((int)*(password + i) >= 65 && (int)*(password + i) <= 90) { result = true; break; } i++; } return result; } bool hasLowerCase(char* password) { bool result = false; int i = 0; while (*(password + i) != '\0') { if ((int)*(password + i) >= 97 && (int)*(password + i) <= 122) { result = true; break; } i++; } return result; } bool hasSpecialCharacter(char* password) { bool result = false; int i = 0; while (*(password + i) != '\0') { if ((int)*(password + i) == 33 || (int)*(password + i) <= 38 && (int)*(password + i) >= 35 || (int)*(password + i) <= 45 && (int)*(password + i) >= 40 || (int)*(password + i) == 64 || (int)*(password + i) == 94) { result = true; break; } i++; } return result; } int minimumNumber(int n, char* password) { // Return the minimum number of characters to make the password strong int needChar = 0; if (!hasDigit(password)) needChar++; if (!hasUpperCase(password)) needChar++; if (!hasLowerCase(password)) needChar++; if (!hasSpecialCharacter(password)) needChar++; int result = 0; int lenCurrentPW = getLength(password); if (lenCurrentPW >= 6) { result = needChar; } else { int delta = 6 - lenCurrentPW; if (delta >= needChar) result = delta; else result = needChar; } return result; } int main() { int n; scanf("%i", &n); char* password = (char *)malloc(512000 * sizeof(char)); scanf("%s", password); int answer = minimumNumber(n, password); printf("%d\n", answer); return 0; }