#include #include #include using namespace std; int main(){ string s; cin>>s; int q; int l[q], int r[q]; int ans[q]; for(int k=0;k>l[k]; cin>>r[k]; string temp= s.substr(l[k]-1,r[k]-l[k]); map m; m.insert(make_pair(temp[0],1)); int i=1; while(temp[i]!='\0'){ if(m.find(temp[i]) != m.end()){ m.at(temp[i])=m.at(temp[i])+1; } else{ m.insert(make_pair(temp[i],1)); } i++; } //traverse the map map :: iterator it; int len=0, flag=0, flageven=0, flagodd; for(it=m.begin();it!=m.end();it++){ if((it->second)%2==0){ len = len+(it->second); flageven=1; } else if(flag==0 && it->second%2==1){ flag=1; len=len+(it->second); } else{ flagodd=1; len = len + (it->second)-1; } } int one=0; for(it=m.begin();it!=m.end();it++){ if(it->second==1 && (flagodd==1 || flageven==1)){ one=one+1; } } ans[k]=one; } for(int i=0;i