import java.io.*; import java.util.*; import java.text.*; import java.math.*; import java.util.regex.*; class pair{ int l,r,v; public pair(int l,int r, int v){ this.l=l; this.r=r; this.v=v; } } public class Solution { static HashSet p; static int a[]; static void initialize(String s) { p=new HashSet<>(); a=new int[s.length()]; for(int i=0;i0) c++; return c; } 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(); } }