#include <bits/stdc++.h>
using namespace std;
const int maxm = 500010;
struct Node {
  int le, ri;
  int ll, lr, rl, rr;
  int lmax1, lmax2, rmax1, rmax2, max1, max2;
  bool tag;
  explicit Node(int le = 0, int ri = 0, int ll = 0, int lr = 0, int rl = 0,
                int rr = 0, int lmax1 = 0, int lmax2 = 0, int rmax1 = 0,
                int rmax2 = 0, int max1 = 0, int max2 = 0, bool tag = false)
      : le(le),
        ri(ri),
        ll(ll),
        lr(lr),
        rl(rl),
        rr(rr),
        lmax1(lmax1),
        lmax2(lmax2),
        rmax1(rmax1),
        rmax2(rmax2),
        max1(max1),
        max2(max2),
        tag(tag){};
  void setSingleLeft() {
    ll = rl = lmax1 = lmax2 = max1 = max2 = rmax1 = rmax2 = 1;
  }
  void setSingleRight() {
    lr = rr = lmax1 = lmax2 = max1 = max2 = rmax1 = rmax2 = 1;
  }
} nodes[maxm << 3];
char c;
void swap(Node& x) {
  swap(x.ll, x.lr);
  swap(x.rl, x.rr);
  swap(x.lmax1, x.lmax2);
  swap(x.rmax1, x.rmax2);
  swap(x.max1, x.max2);
}
Node merge(Node x, Node y) {
  if (x.tag) {
    x.tag = false;
    swap(x);
  }
  if (y.tag) {
    y.tag = false;
    swap(y);
  }
  bool allxll = (x.ll == x.ri - x.le), allxlr = (x.lr == x.ri - x.le),
       allyrr = (y.rr == y.ri - y.le), allyrl = (y.rl == y.ri - y.le);
  return Node(x.le, y.ri, allxll ? x.ll + y.ll : x.ll,
              allxlr ? x.lr + y.lr : x.lr, allyrl ? x.rl + y.rl : y.rl,
              allyrr ? x.rr + y.rr : y.rr,
              max(x.lmax1 + (x.lmax1 == x.ri - x.le ? y.ll : 0),
                  allxlr ? x.lr + y.lmax1 : 0),
              max(x.lmax2 + (x.lmax2 == x.ri - x.le ? y.lr : 0),
                  allxll ? x.ll + y.lmax2 : 0),
              max(y.rmax1 + (y.rmax1 == y.ri - y.le ? x.rr : 0),
                  allyrl ? x.rmax1 + y.rl : 0),
              max(y.rmax2 + (y.rmax2 == y.ri - y.le ? x.rl : 0),
                  allyrr ? x.rmax2 + y.rr : 0),
              max({x.max1, y.max1, x.rmax1 + y.ll, y.lmax1 + x.rr}),
              max({x.max2, y.max2, x.rmax2 + y.lr, y.lmax2 + x.rl}));
}
void pushdown(int now) {
  if (nodes[now].tag) {
    nodes[now].tag = 0;
    nodes[(now << 1)].tag ^= 1, nodes[(now << 1 | 1)].tag ^= 1;
    swap(nodes[now]);
  }
}
void modify(int now, int le, int ri) {
  if (le == nodes[now].le && ri == nodes[now].ri)
    nodes[now].tag ^= 1;
  else {
    pushdown(now);
    if (le >= ((nodes[now].le + nodes[now].ri) >> 1))
      modify((now << 1 | 1), le, ri);
    else if (ri <= ((nodes[now].le + nodes[now].ri) >> 1))
      modify((now << 1), le, ri);
    else {
      modify((now << 1), le, ((nodes[now].le + nodes[now].ri) >> 1));
      modify((now << 1 | 1), ((nodes[now].le + nodes[now].ri) >> 1), ri);
    }
    nodes[now] = merge(nodes[(now << 1)], nodes[(now << 1 | 1)]);
  }
}
void init(int now, int le, int ri) {
  nodes[now].le = le, nodes[now].ri = ri;
  if (le + 1 == ri) {
    cin >> c;
    if (c == '<')
      nodes[now].setSingleLeft();
    else
      nodes[now].setSingleRight();
  } else {
    init((now << 1), le, ((nodes[now].le + nodes[now].ri) >> 1));
    init((now << 1 | 1), ((nodes[now].le + nodes[now].ri) >> 1), ri);
    nodes[now] = merge(nodes[(now << 1)], nodes[(now << 1 | 1)]);
  }
}
Node ask(int now, int le, int ri) {
  pushdown(now);
  if (le == nodes[now].le && ri == nodes[now].ri)
    return nodes[now];
  else {
    if (le >= ((nodes[now].le + nodes[now].ri) >> 1))
      return ask((now << 1 | 1), le, ri);
    else if (ri <= ((nodes[now].le + nodes[now].ri) >> 1))
      return ask((now << 1), le, ri);
    else
      return merge(
          ask((now << 1), le, ((nodes[now].le + nodes[now].ri) >> 1)),
          ask((now << 1 | 1), ((nodes[now].le + nodes[now].ri) >> 1), ri));
  }
}
int n, m;
int main() {
  ios_base::sync_with_stdio(0);
  cin >> n >> m;
  init(1, 1, n + 1);
  for (int i = 1, l, r; i <= m; ++i) {
    cin >> l >> r;
    modify(1, l, r + 1);
    auto res = ask(1, l, r + 1);
    cout << (res.tag ? res.max2 : res.max1) << "\n";
  }
  return 0;
}
