Ilya the Lion wants to help all his friends with passing exams. They need to solve the following problem to pass the IT exam.

You've got string *s* = *s*<sub class="lower-index">1</sub>*s*<sub class="lower-index">2</sub>... *s*<sub class="lower-index">*n*</sub> (*n* is the length of the string), consisting only of characters "." and "#" and *m* queries. Each query is described by a pair of integers *l*<sub class="lower-index">*i*</sub>, *r*<sub class="lower-index">*i*</sub> (1 ≤ *l*<sub class="lower-index">*i*</sub> &lt; *r*<sub class="lower-index">*i*</sub> ≤ *n*). The answer to the query *l*<sub class="lower-index">*i*</sub>, *r*<sub class="lower-index">*i*</sub> is the number of such integers *i* (*l*<sub class="lower-index">*i*</sub> ≤ *i* &lt; *r*<sub class="lower-index">*i*</sub>), that *s*<sub class="lower-index">*i*</sub> = *s*<sub class="lower-index">*i* + 1</sub>.

Ilya the Lion wants to help his friends but is there anyone to help him? Help Ilya, solve the problem.
The first line contains string *s* of length *n* (2 ≤ *n* ≤ 10<sup class="upper-index">5</sup>). It is guaranteed that the given string only consists of characters "." and "#".

The next line contains integer *m* (1 ≤ *m* ≤ 10<sup class="upper-index">5</sup>) — the number of queries. Each of the next *m* lines contains the description of the corresponding query. The *i*-th line contains integers *l*<sub class="lower-index">*i*</sub>, *r*<sub class="lower-index">*i*</sub> (1 ≤ *l*<sub class="lower-index">*i*</sub> &lt; *r*<sub class="lower-index">*i*</sub> ≤ *n*).
import sys, io, os
import math
import bisect
import heapq
import string
from collections import defaultdict,Counter,deque
input = sys.stdin.readline
 
def I():
    return input()
 
def II():
    return int(input())
 
def MII():
    return map(int, input().split())
 
def LI():
    return list(input().split())
 
def LII():
    return list(map(int, input().split()))
 
def GMI():
    return map(lambda x: int(x) - 1, input().split())
 
def LGMI():
    return list(map(lambda x: int(x) - 1, input().split()))
 
def WRITE(out):
  return print('\n'.join(map(str, out)))
 
def WS(out):
  return print(' '.join(map(str, out)))
 
def WNS(out):
  return print(''.join(map(str, out)))

def WSNOPRINT(out):
  return ''.join(map(str, out))

'''
'''
def solve():
    s = [x for x in I().strip()]
    t = II()

    dp = [0] * len(s)
    for i in range(1, len(s)):
        if s[i] == s[i-1]:
            dp[i] = 1
    for i in range(len(dp)):
        dp[i] += dp[i-1]

    # print(dp)
    for _ in range(t):
        l, r = MII()
        r -= 1
        l -= 1
        print(dp[r] - dp[l])



solve()