import java.io.*; import java.util.*; import java.text.*; import java.math.*; import java.util.regex.*; public class Solution { static String s; static void initialize(String ss) { // This function is called once before all queries. s=ss; } static int answerQuery(int l, int r) { // Return the answer for this query modulo 1000000007. char[] temp=s.substring(l, r).toCharArray(); Map m=new HashMap<>(); boolean flag=false; for(int i=0;i entry : m.entrySet()) { int z=entry.getValue(); x+=z/2; if(z%2==1) flag=true; } if(flag) return x+1; return x; } public static void main(String[] args) { Scanner in = new Scanner(System.in); String s = in.next(); initialize(s); int q = in.nextInt(); for(int a0 = 0; a0 < q; a0++){ int l = in.nextInt(); int r = in.nextInt(); int result = answerQuery(l, r); System.out.println(result); } in.close(); } }