#include <bits/stdc++.h>
using namespace std;
const long long MOD = (long long)1e9 + 7;
const long double PI = 3.141592653589793238462643383279502884197;
long long fac[1] = {1}, inv[1] = {1};
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
long long mp(long long a, long long b) {
  long long ret = 1;
  while (b) {
    if (b & 1) ret = ret * a % MOD;
    a = a * a % MOD;
    b >>= 1;
  }
  return ret;
}
long long cmb(long long r, long long c) {
  return fac[r] * inv[c] % MOD * inv[r - c] % MOD;
}
priority_queue<int, vector<int>, greater<int>> pq;
vector<int> v;
char s[500001];
int szz = 1 << 19;
struct node {
  int lv, lc, slc, rv, rc, src, rotn, mav;
  void debug() {
    printf("%d %d %d %d %d %d %d %d\n", lv, lc, slc, rv, rc, src, rotn, mav);
  }
} tr[2][1 << 20];
int lazy[1 << 20];
node merge(node a, node b) {
  if (a.rotn == -1) return b;
  if (b.rotn == -1) return a;
  node ret = {a.lv,
              a.lc,
              a.slc,
              b.rv,
              b.rc,
              b.src,
              a.rotn + b.rotn - 1,
              max(a.mav, b.mav)};
  if (a.lv == b.lv && a.rotn == 1)
    ret.lc += b.lc, ret.slc = b.slc;
  else if (a.rotn == 1)
    ret.slc = b.lc;
  if (a.rv == b.rv && b.rotn == 1)
    ret.rc += a.rc, ret.src = a.src;
  else if (b.rotn == 1)
    ret.src = a.rc;
  if (a.rv == b.lv) {
    if (a.rv == 0)
      ret.mav = max(ret.mav, b.lc + a.rc + a.src);
    else
      ret.mav = max(ret.mav, b.lc + a.rc + b.slc);
    if (a.rotn == 2) ret.slc = b.lc + a.rc;
    if (b.rotn == 2) ret.src = b.lc + a.rc;
  } else {
    ret.rotn++;
    if (a.rv == 1) ret.mav = max(ret.mav, a.rc + b.lc);
  }
  ret.mav = max(ret.mav, ret.lc);
  ret.mav = max(ret.mav, ret.rc);
  return ret;
}
node find(int i, int l, int r, int le, int ri, int val) {
  val ^= lazy[i];
  if (l > ri || r < le) return {0, 0, 0, 0, 0, 0, -1, 0};
  if (l <= le && ri <= r) {
    lazy[i] ^= 1;
    val ^= 1;
    return tr[val][i];
  }
  node ret = merge(find(i * 2, l, r, le, (le + ri) / 2, val),
                   find(i * 2 + 1, l, r, (le + ri) / 2 + 1, ri, val));
  tr[0][i] = merge(tr[lazy[i * 2]][i * 2], tr[lazy[i * 2 + 1]][i * 2 + 1]);
  tr[1][i] =
      merge(tr[lazy[i * 2] ^ 1][i * 2], tr[lazy[i * 2 + 1] ^ 1][i * 2 + 1]);
  return ret;
}
void init(int i) {
  if (i >= szz) return;
  init(i * 2);
  init(i * 2 + 1);
  tr[0][i] = merge(tr[0][i * 2], tr[0][i * 2 + 1]);
  tr[1][i] = merge(tr[1][i * 2], tr[1][i * 2 + 1]);
}
int main() {
  memset(tr, -1, sizeof(tr));
  int n, m;
  scanf("%d %d", &n, &m);
  scanf("%s", s);
  for (int i = 0; i < n; i++) {
    if (s[i] == '<')
      tr[0][i + szz] = {0, 1, 0, 0, 1, 0, 1, 1};
    else
      tr[0][i + szz] = {1, 1, 0, 1, 1, 0, 1, 1};
    tr[1][i + szz] = tr[0][i + szz];
    tr[1][i + szz].lv ^= 1, tr[1][i + szz].rv ^= 1;
  }
  init(1);
  int a, b;
  for (int i = 0; i < m; i++) {
    scanf("%d %d", &a, &b);
    a--;
    b--;
    printf("%d\n", find(1, a, b, 0, szz - 1, 0).mav);
  }
}
