import java.io.*; import java.util.*; import java.text.*; import java.math.*; import java.util.regex.*; public class Solution { static int answerQuery(String s, int l, int r) { String s1 = s.substring(l,r); int n = s1.length(); int ec=0, oc=0; for(char i='a';i<='z';i++) { String s2 = s1.replaceAll(String.valueOf(i),""); if(n-s2.length() > 0) if((n-s2.length())%2 == 0) ec++; else oc++; } if(ec > 0) if(oc > 0) return oc; else return ec; else return 0; // Return the answer for this query modulo 1000000007. } public static void main(String[] args) { Scanner in = new Scanner(System.in); String s = in.next(); int q = in.nextInt(); for(int a0 = 0; a0 < q; a0++){ int l = in.nextInt(); int r = in.nextInt(); int result = answerQuery(s, l-1, r); System.out.println(result); } in.close(); } }