#include #include #include #include #include #include #include int b[26]={0}; int answerQuery(int l, int r,int c[26]) { int i,count=0,p=0; for(i=0;i<26;i++){ if(c[i]%2==0){ count+=(c[i]/2); } else if(c[i]%2!=0){ count+=(c[i]-1)/2; p++; } c[i]=0; } if(p>=1) return count+1; else{ return count; } } int main() { char* s = (char *)malloc(512000 * sizeof(char)); scanf("%s", s); int *c=(int *)malloc(26*sizeof(int)); int q,i; scanf("%i", &q); for(int a0 = 0; a0 < q; a0++){ int l; int r; scanf("%i %i", &l, &r); for(i=l;i<=r;i++){ c[s[i]-'a']++; } int result = answerQuery(l, r,c); printf("%d\n", result); } return 0; }