fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main() {
  5. string input;
  6. cin >> input;
  7. int LIS[55];
  8. LIS[0] = 1;
  9. for(int i = 1; i < input.size(); i++) {
  10. LIS[i] = 1;
  11. for(int j = 0; j < i; j++)
  12. if(input[j] < input[i])
  13. LIS[i] = max(LIS[i], LIS[j]+1);
  14. }
  15. int ans = -1;
  16. for(int i = 0; i < input.size(); i++)
  17. ans = max(ans, LIS[i]);
  18. cout << 26-ans << endl;
  19. return 0;
  20. }
Success #stdin #stdout 0s 5308KB
stdin
aiemckgobjfndlhp
stdout
20