#include <bits/stdc++.h>
using namespace std;
const int N = 5e5 + 10;
int n, q, l, r;
char s[N];
struct node {
  int l, r, pl, pr, plr, prl, sl, sr, slr, srl, mxlr, mxrl;
  bool tag;
  void init() {
    pl = pr = plr = prl = sl = sr = slr = srl = mxlr = mxrl = tag = 0;
  }
  void out() {
    printf(
        "l:%d r:%d pl:%d pr:%d plr:%d prl:%d sl:%d sr:%d slr:%d srl:%d mxlr:%d "
        "mxrl:%d\n",
        l, r, pl, pr, plr, prl, sl, sr, slr, srl, mxlr, mxrl);
  }
  node() { init(); }
} e[5 * N];
node merge(node a, node b) {
  node c;
  c.l = a.l;
  c.r = b.r;
  c.pl = a.pl;
  if (a.pl == a.r - a.l + 1) c.pl += b.pl;
  c.pr = a.pr;
  if (a.pr == a.r - a.l + 1) c.pr += b.pr;
  c.sl = b.sl;
  if (b.sl == b.r - b.l + 1) c.sl += a.sl;
  c.sr = b.sr;
  if (b.sr == b.r - b.l + 1) c.sr += a.sr;
  c.plr = a.plr;
  if (a.plr == a.r - a.l + 1) c.plr += b.pr;
  if (a.pl == a.r - a.l + 1) {
    if (b.pr > 0) c.plr = a.pl + b.pr;
    if (b.plr > 0) c.plr = a.pl + b.plr;
  }
  c.prl = a.prl;
  if (a.prl == a.r - a.l + 1) c.prl += b.pl;
  if (a.pr == a.r - a.l + 1) {
    if (b.pl > 0) c.prl = a.pr + b.pl;
    if (b.prl > 0) c.prl = a.pr + b.prl;
  }
  c.slr = b.slr;
  if (b.slr == b.r - b.l + 1) c.slr += a.sl;
  if (b.sr == b.r - b.l + 1) {
    if (a.sl > 0) c.slr = a.sl + b.sr;
    if (a.slr > 0) c.slr = a.slr + b.sr;
  }
  c.srl = b.srl;
  if (b.srl == b.r - b.l + 1) c.srl += a.sr;
  if (b.sl == b.r - b.l + 1) {
    if (a.sr > 0) c.srl = a.sr + b.sl;
    if (a.srl > 0) c.srl = a.srl + b.sl;
  }
  c.mxlr = max(c.plr, c.slr);
  if (a.sl > 0 && b.pr > 0) c.mxlr = max(c.mxlr, a.sl + b.pr);
  if (b.plr > 0) c.mxlr = max(c.mxlr, a.sl + b.plr);
  if (a.slr > 0) c.mxlr = max(c.mxlr, a.slr + b.pr);
  c.mxlr = max(c.mxlr, max(a.mxlr, b.mxlr));
  c.mxrl = max(c.prl, c.srl);
  if (a.sr > 0 && b.pl > 0) c.mxrl = max(c.mxrl, a.sr + b.pl);
  if (b.prl > 0) c.mxrl = max(c.mxrl, a.sr + b.prl);
  if (a.srl > 0) c.mxrl = max(c.mxrl, a.srl + b.pl);
  c.mxrl = max(c.mxrl, max(a.mxrl, b.mxrl));
  return c;
}
void bld(int p, int l, int r) {
  e[p].init();
  e[p].l = l, e[p].r = r;
  if (l == r) {
    if (s[l] == '<')
      e[p].pl = e[p].sl = 1;
    else
      e[p].pr = e[p].sr = 1;
    return;
  }
  int mid = (l + r) / 2;
  bld(p << 1, l, mid);
  bld(p << 1 | 1, mid + 1, r);
  e[p] = merge(e[p << 1], e[p << 1 | 1]);
}
void flip(int p) {
  swap(e[p].pl, e[p].pr), swap(e[p].sl, e[p].sr);
  swap(e[p].plr, e[p].prl), swap(e[p].slr, e[p].srl),
      swap(e[p].mxlr, e[p].mxrl);
  e[p].tag ^= 1;
}
void psd(int p) {
  if (e[p].tag) {
    flip(p << 1), flip(p << 1 | 1);
    e[p].tag = 0;
  }
}
node ask(int p, int ql, int qr) {
  if (e[p].l == ql && e[p].r == qr) {
    flip(p);
    return e[p];
  }
  psd(p);
  int mid = (e[p].l + e[p].r) / 2;
  node ans;
  if (qr <= mid)
    ans = ask(p << 1, ql, qr);
  else if (ql > mid)
    ans = ask(p << 1 | 1, ql, qr);
  else
    ans = merge(ask(p << 1, ql, mid), ask(p << 1 | 1, mid + 1, qr));
  e[p] = merge(e[p << 1], e[p << 1 | 1]);
  return ans;
}
int main() {
  scanf("%d%d", &n, &q);
  scanf("%s", s + 1);
  bld(1, 1, n);
  while (q--) {
    scanf("%d%d", &l, &r);
    node ans = ask(1, l, r);
    printf("%d\n", max(ans.mxrl, max(ans.pl, ans.sr)));
  }
  return 0;
}
