using System; using System.Collections.Generic; using System.IO; using System.Linq; class Solution { static char[] c; static void initialize(string s) { c = s.ToCharArray(); //Array.Sort(c); } static int answerQuery(int l, int r) { // Return the answer for this query modulo 1000000007. int count = 0; int dcount = 0; int size = r - l +1; int sin = 0; char[] c1 = new char[size]; for(int i = 0, j = (l-1); i < size; i++, j++) c1[i] = c[j]; Array.Sort(c1); char temp = c1[0]; for(int i = 0; i < size; i++) { //Console.WriteLine(temp); if (temp == '%') { temp = c1[i]; count = 1; } else if (temp == c1[i]) count += 1; else { count = 1; temp = c1[i]; sin += 1; } //Console.WriteLine(count); if(count == 2) { dcount += 1; temp = '%'; count = 0; } } //Console.WriteLine(dcount); //return dcount == 0 ? 1 : dcount*((r-l+1)/2); return dcount + sin; } static void Main(String[] args) { string s = Console.ReadLine(); initialize(s); int q = Convert.ToInt32(Console.ReadLine()); for(int a0 = 0; a0 < q; a0++){ string[] tokens_l = Console.ReadLine().Split(' '); int l = Convert.ToInt32(tokens_l[0]); int r = Convert.ToInt32(tokens_l[1]); int result = answerQuery(l, r); Console.WriteLine(result); } } }