循环遍历即可
#include<bits/stdc++.h>
using namespace std;
string s;
int a[26] = {0};
int main(){
cin >> s;
for(int i = 0;i < s.length();i++){
a[s[i] - 'a']++;
}
int Min = 1001;
int Max = -1;
for(int i = 0;i < 26;i++){
if(a[i] != 0){
Min = min(Min,a[i]);
Max = max(Max,a[i]);
}
}
cout << Max - Min;
}