#include #include #include #include #include using namespace std; typedef long long ll; ll M=1000000007; int main() { /* Enter your code here. Read input from STDIN. Print output to STDOUT */ string s; ll l,r,t; int A[26]={0}; bool f[26]={false}; cin >> s; for(int i=0;i<26;i++) A[s[i]-97]++; cin >> t; while(t--) { cin >> l >> r; for(int i=0;i<26;i++) f[i]=false; ll c=0; for(int i=l;i<=r;i++) { if(f[s[i]-97]==false) { if(A[s[i]-97]%2==1) { c++; } f[s[i]-97]=true; } } cout << c << endl; } return 0; }