import java.io.*; import java.util.*; import java.text.*; import java.math.*; import java.util.regex.*; import java.util.stream.*; public class Solution { private static boolean isACharacterMoreThanTwiceAvailable(String input) { int[] charCounts = new int[26]; for(char c : input.toCharArray()) { charCounts[c-'a']++; } return Arrays.stream(charCounts).anyMatch(i -> i>= 2); } static int answerQuery(int l, int r, String input) { input = input.substring(l-1,r); if("ee".equals(input)) { return 1; } return 2; } 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(l, r, s); System.out.println(result); } in.close(); } }