#include using namespace std; string lg; map freq; void initialize(string s) { // This function is called once before all queries. map::iterator it; lg=s; for (int i=0; isecond ++; else freq[s[i]]=1; } } int answerQuery(int l, int r) { // Return the answer for this query modulo 1000000007. map::iterator it; vector pos; for (int i=l; i<=r; i++){ it = freq.find(lg[i]); if (it->second % 2 ==0) pos.push_back(it->second); } return (1+pos.size())/2 ; } int main() { string s; cin >> s; initialize(s); int q; cin >> q; for(int a0 = 0; a0 < q; a0++){ int l; int r; cin >> l >> r; int result = answerQuery(l, r); cout << result << endl; } return 0; }