#include using namespace std; int main() { string s; cin >> s; int q; cin >> q; for(int a0 = 0; a0 < q; a0++){ int l; int r; cin >> l >> r; string sub[r-l+1]; int times[r-l+1] = {1}; for (int i = 0; i < r-l; i++) times[i] = 1; int palin = 0; for (int i = 0; i < r-l; i++ ) sub[i] = s[i+l-1]; for (int i = 0; i < r-l; i++ ) { for(int j = 0; j < r-l; j++) if (sub[j]==sub[i]) { times[i]++; } } for (int i = 0; i < r-l; i++) if (times[i]%2==1) palin++; if (palin == 0) palin = 1; cout << palin << endl; } return 0; }