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*).
class tree_array:
    tree=[0]
    l=0
    def lowbit(self,x):
        return x&-x
    def __init__(self,arr) -> None:
        self.l=len(arr)
        self.tree=[0 for i in range(self.l+1)]
        for i in range(1,self.l+1):
            self.tree[i] += arr[i-1]
            if (fa := i+self.lowbit(i)) <= self.l:
                self.tree[fa] += self.tree[i]
    def add(self,x,k):
        #x是从1开始的下标
        while(x<=self.l):
            self.tree[x]+=k
            x+=self.lowbit(x)
    def query(self,x,y):
        #x,y是从1开始的下标
        #是原数组[x+1,y]的和
        ans=0
        while y>x:
            ans+=self.tree[y]
            y-=self.lowbit(y)
        while x>y:
            ans-=self.tree[x]
            x-=self.lowbit(x)
        return ans
s=input()
l=len(s)
arr=[]
for i in range(l-1):
    arr.append(int(s[i]==s[i+1]))
tree=tree_array(arr)
m=int(input())
for i in range(m):
    l,r=map(int,input().split())
    print(tree.query(l,r-1)+arr[l-1])