#include <iostream>
#include<map>
#include<string>
using namespace std;
int main()
{
string str;
cin>>str;
int i,j;
map<char,int>h;
for(auto s:str){
h[s]++;
}
int minop=h[str[0]];
int maxop=h[str[0]];
for(auto s:str){
maxop=max(maxop,h[s]);
minop=min(minop,h[s]);
}
cout<<maxop-minop;
// 请在此输入您的代码
return 0;
}