#include using namespace std; int minimumNumber(int n, string password) { string numbers = "0123456789"; string lower_case = "abcdefghijklmnopqrstuvwxyz"; string upper_case = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; string special_characters = "!@#$%^&*()-+"; int lenFlag = 0, num = 0, lc = 0, uc = 0, sc = 0; int len = 0; if (n < 6) len = 6-n; for (int i = 0 ; i < n ; i++) { if (numbers.find(password[i]) !=std::string::npos) { num =1; } if (lower_case.find(password[i]) !=std::string::npos) { lc =1; } if (upper_case.find(password[i]) !=std::string::npos) { uc =1; } if (special_characters.find(password[i]) !=std::string::npos) { sc =1; } if (num == 1 && lc == 1 && uc == 1 && sc ==1) break; } int tempLen = 0; if (num == 0) ++tempLen; if (sc == 0) ++tempLen; if (uc == 0) ++tempLen; if (lc == 0) ++tempLen; if (len > tempLen) return len; else return tempLen; // Return the minimum number of characters to make the password strong } int main() { int n; cin >> n; string password; cin >> password; int answer = minimumNumber(n, password); cout << answer << endl; return 0; }