#!/bin/python3 import sys def initialize(s): string = [i for i in s] return string def answerQuery(l, r): a = ((r - l) + 1)//2 return a if __name__ == "__main__": s = input().strip() initialize(s) q = int(input().strip()) for a0 in range(q): l, r = input().strip().split(' ') l, r = [int(l), int(r)] result = answerQuery(l, r) print(result)