#include <bits/stdc++.h>
using namespace std;
template <int input_buf_size, int output_buf_size>
class FastIO {
  char cbuf[input_buf_size + 1];
  int icur = 0;
  inline bool go_to_next_token() {
    while (cbuf[icur] == ' ' || cbuf[icur] == '\n') icur++;
    while (cbuf[icur] == 0) {
      icur = 0;
      if (fgets(cbuf, sizeof(cbuf), stdin) != cbuf) return false;
      while (cbuf[icur] == ' ' || cbuf[icur] == '\n') icur++;
    }
    return true;
  }

 public:
  string readString() {
    assert(go_to_next_token());
    string ans;
    while (cbuf[icur] != ' ' && cbuf[icur] != '\n' && cbuf[icur] != 0)
      ans.push_back(cbuf[icur++]);
    ans.shrink_to_fit();
    return ans;
  }
  template <class int_type>
  int_type readInt() {
    assert(go_to_next_token());
    int_type x = 0;
    bool m = cbuf[icur] == '-';
    if (m) icur++;
    while ('0' <= cbuf[icur] && cbuf[icur] <= '9') {
      x *= 10;
      x += (cbuf[icur] - '0');
      icur++;
    }
    if (m) x = -x;
    return x;
  }
  bool seekEof() { return !go_to_next_token(); }

 private:
  char obuf[output_buf_size + 1];
  int ocur = 0;
  inline void write_string(const char *str, size_t sz = 0) {
    if (sz == 0) sz = strlen(str);
    if (ocur + sz > output_buf_size) {
      fputs(obuf, stdout);
      fputs(str, stdout);
      ocur = 0;
      obuf[0] = 0;
      return;
    }
    strcpy(obuf + ocur, str);
    ocur += sz;
    obuf[ocur] = 0;
  }

 public:
  template <class int_type>
  void writeInt(int_type x, bool sp = true) {
    char buf[20];
    int c = 0;
    if (x < 0) {
      buf[c++] = '-';
      x = -x;
    }
    int s = c;
    if (x == 0) {
      buf[c++] = '0';
    }
    while (x > 0) {
      buf[c++] = (x % 10) + '0';
      x /= 10;
    }
    for (int i = 0; 2 * i < c - s; i++) {
      swap(buf[s + i], buf[c - 1 - i]);
    }
    buf[c] = 0;
    write_string(buf, c);
    if (sp) write_string(" ", 1);
  }
  void writeString(string s, bool space = true) {
    write_string(s.c_str(), s.size());
    if (space) write_string(" ", 1);
  }
  void writeEndl() { write_string("\n", 1); }
  void flush() {
    fputs(obuf, stdout);
    ocur = 0;
    obuf[0] = 0;
  }

 private:
  bool lflush;

 public:
  FastIO(bool local_flush) {
    obuf[0] = 0;
    lflush = local_flush;
  }
  ~FastIO() { fputs(obuf, stdout); }
};
FastIO<10000000, 10000000> IO(true);
const int upper_inf = numeric_limits<int>::max();
const int lower_inf = numeric_limits<int>::min();
const string task = "DBG";
const int N = 1e6 + 9;
const int M = 1e9 + 7;
auto ans = 0;
void init();
void reset();
void input();
void solve();
void ouput();
int tester(int nT);
int main() {
  init();
  reset();
  input();
  solve();
  ouput();
  return 0;
}
void init() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
}
void reset() {}
int n, a[N];
string s;
void input() { s = IO.readString(); }
void solve() {
  n = (int)s.size();
  for (int i = 0; i < n - 1; i++)
    a[i] = (s[i] == s[i + 1]), a[i] += i ? a[i - 1] : 0;
  int q = IO.readInt<int>();
  while (q--) {
    int l = IO.readInt<int>();
    int r = IO.readInt<int>();
    IO.writeInt<int>(a[--r - 1] - a[--l - 1]);
    IO.writeEndl();
  }
}
void ouput() {}
void gen() {
  srand(time(NULL));
  ofstream fi((task + ".INP").c_str());
  fi.close();
}
int checker() { return 0; }
int tester(int nT) {
  for (int iT = 1; iT <= nT; iT++) {
    cerr << "Test " << iT << ": ";
    gen();
    clock_t t0 = clock();
    init();
    reset();
    input();
    solve();
    clock_t t1 = clock();
    int temp = checker();
    if (temp == ans)
      cerr << "Passed";
    else
      return cerr << "Wrong, answer must be " << temp << ", not " << ans, 1;
    fprintf(stderr, " - %.4lfs.\n", (double)(t1 - t0) / 1000);
  }
  return 0;
}

### Prompt

In CPP, your task is to solve the following problem:

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 = s1s2... sn (n is the length of the string), consisting only of characters "." and "#" and m queries. Each query is described by a pair of integers li, ri (1 ≤ li < ri ≤ n). The answer to the query li, ri is the number of such integers i (li ≤ i < ri), that si = si + 1.

Ilya the Lion wants to help his friends but is there anyone to help him? Help Ilya, solve the problem.

Input

The first line contains string s of length n (2 ≤ n ≤ 105). It is guaranteed that the given string only consists of characters "." and "#".

The next line contains integer m (1 ≤ m ≤ 105) — the number of queries. Each of the next m lines contains the description of the corresponding query. The i-th line contains integers li, ri (1 ≤ li < ri ≤ n).

Output

Print m integers — the answers to the queries in the order in which they are given in the input.

Examples

Input

......
4
3 4
2 3
1 6
2 6


Output

1
1
5
4


Input

#..###
5
1 3
5 6
1 5
3 6
3 4


Output

1
1
2
2
0

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
template <int input_buf_size, int output_buf_size>
class FastIO {
  char cbuf[input_buf_size + 1];
  int icur = 0;
  inline bool go_to_next_token() {
    while (cbuf[icur] == ' ' || cbuf[icur] == '\n') icur++;
    while (cbuf[icur] == 0) {
      icur = 0;
      if (fgets(cbuf, sizeof(cbuf), stdin) != cbuf) return false;
      while (cbuf[icur] == ' ' || cbuf[icur] == '\n') icur++;
    }
    return true;
  }

 public:
  string readString() {
    assert(go_to_next_token());
    string ans;
    while (cbuf[icur] != ' ' && cbuf[icur] != '\n' && cbuf[icur] != 0)
      ans.push_back(cbuf[icur++]);
    ans.shrink_to_fit();
    return ans;
  }
  template <class int_type>
  int_type readInt() {
    assert(go_to_next_token());
    int_type x = 0;
    bool m = cbuf[icur] == '-';
    if (m) icur++;
    while ('0' <= cbuf[icur] && cbuf[icur] <= '9') {
      x *= 10;
      x += (cbuf[icur] - '0');
      icur++;
    }
    if (m) x = -x;
    return x;
  }
  bool seekEof() { return !go_to_next_token(); }

 private:
  char obuf[output_buf_size + 1];
  int ocur = 0;
  inline void write_string(const char *str, size_t sz = 0) {
    if (sz == 0) sz = strlen(str);
    if (ocur + sz > output_buf_size) {
      fputs(obuf, stdout);
      fputs(str, stdout);
      ocur = 0;
      obuf[0] = 0;
      return;
    }
    strcpy(obuf + ocur, str);
    ocur += sz;
    obuf[ocur] = 0;
  }

 public:
  template <class int_type>
  void writeInt(int_type x, bool sp = true) {
    char buf[20];
    int c = 0;
    if (x < 0) {
      buf[c++] = '-';
      x = -x;
    }
    int s = c;
    if (x == 0) {
      buf[c++] = '0';
    }
    while (x > 0) {
      buf[c++] = (x % 10) + '0';
      x /= 10;
    }
    for (int i = 0; 2 * i < c - s; i++) {
      swap(buf[s + i], buf[c - 1 - i]);
    }
    buf[c] = 0;
    write_string(buf, c);
    if (sp) write_string(" ", 1);
  }
  void writeString(string s, bool space = true) {
    write_string(s.c_str(), s.size());
    if (space) write_string(" ", 1);
  }
  void writeEndl() { write_string("\n", 1); }
  void flush() {
    fputs(obuf, stdout);
    ocur = 0;
    obuf[0] = 0;
  }

 private:
  bool lflush;

 public:
  FastIO(bool local_flush) {
    obuf[0] = 0;
    lflush = local_flush;
  }
  ~FastIO() { fputs(obuf, stdout); }
};
FastIO<10000000, 10000000> IO(true);
const int upper_inf = numeric_limits<int>::max();
const int lower_inf = numeric_limits<int>::min();
const string task = "DBG";
const int N = 1e6 + 9;
const int M = 1e9 + 7;
auto ans = 0;
void init();
void reset();
void input();
void solve();
void ouput();
int tester(int nT);
int main() {
  init();
  reset();
  input();
  solve();
  ouput();
  return 0;
}
void init() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
}
void reset() {}
int n, a[N];
string s;
void input() { s = IO.readString(); }
void solve() {
  n = (int)s.size();
  for (int i = 0; i < n - 1; i++)
    a[i] = (s[i] == s[i + 1]), a[i] += i ? a[i - 1] : 0;
  int q = IO.readInt<int>();
  while (q--) {
    int l = IO.readInt<int>();
    int r = IO.readInt<int>();
    IO.writeInt<int>(a[--r - 1] - a[--l - 1]);
    IO.writeEndl();
  }
}
void ouput() {}
void gen() {
  srand(time(NULL));
  ofstream fi((task + ".INP").c_str());
  fi.close();
}
int checker() { return 0; }
int tester(int nT) {
  for (int iT = 1; iT <= nT; iT++) {
    cerr << "Test " << iT << ": ";
    gen();
    clock_t t0 = clock();
    init();
    reset();
    input();
    solve();
    clock_t t1 = clock();
    int temp = checker();
    if (temp == ans)
      cerr << "Passed";
    else
      return cerr << "Wrong, answer must be " << temp << ", not " << ans, 1;
    fprintf(stderr, " - %.4lfs.\n", (double)(t1 - t0) / 1000);
  }
  return 0;
}

```