#include <bits/stdc++.h>
using namespace std;
struct node {
  int fl = 0, mx = 0, pl = 0, sl = 0;
  string pf, sf;
};
const int N = 5e5 + 9;
node tr[4 * N][2];
int n, q, lz[4 * N];
string st;
node merge(node x, node y) {
  node r;
  if (x.fl and y.fl) {
    if (x.pf.back() == '<' and y.pf.front() == '>') {
      r.pf = x.pf, r.sf = y.pf;
      r.pl = x.pl, r.sl = y.pl;
      r.mx = max(x.mx, y.mx);
    } else {
      r.pf = x.pf + y.pf;
      r.pl = x.pl + y.pl;
      r.fl = 1;
      r.mx = r.pl;
    }
  } else if (x.fl) {
    r.sf = y.sf;
    r.sl = y.sl;
    if (x.pf.back() == '<' and y.pf.front() == '>') {
      r.pf = x.pf;
      r.pl = x.pl;
      r.mx = max(x.mx, y.mx);
    } else {
      r.pf = x.pf + y.pf;
      r.pl = x.pl + y.pl;
      r.mx = max(r.pl, y.mx);
    }
  } else if (y.fl) {
    r.pf = x.pf;
    r.pl = x.pl;
    if (x.sf.back() == '<' and y.pf.front() == '>') {
      r.sf = y.pf;
      r.sl = y.pl;
      r.mx = max(x.mx, y.mx);
    } else {
      r.sf = x.sf + y.pf;
      r.sl = x.sl + y.pl;
      r.mx = max(r.sl, x.mx);
    }
  } else {
    r.pf = x.pf, r.sf = y.sf;
    r.pl = x.pl, r.sl = y.sl;
    r.mx = max(x.mx, y.mx);
    if (!(x.sf.back() == '<' and y.pf.front() == '>'))
      r.mx = max(r.mx, x.sl + y.pl);
  }
  if (r.pf.size() > 2) {
    string tmp = "";
    tmp += r.pf.front();
    tmp += r.pf.back();
    r.pf = tmp;
  }
  if (r.sf.size() > 2) {
    string tmp = "";
    tmp += r.sf.front();
    tmp += r.sf.back();
    r.sf = tmp;
  }
  return r;
}
void build(int id = 1, int l = 1, int r = n) {
  if (l == r) {
    tr[id][0].mx = 1, tr[id][1].mx = 1;
    tr[id][0].pf = '<', tr[id][1].pf = '>';
    tr[id][0].fl = tr[id][1].fl = 1;
    tr[id][0].pl = tr[id][1].pl = 1;
    if (st[l] == '>') swap(tr[id][0].pf, tr[id][1].pf);
    return;
  }
  int mid = (l + r) / 2;
  build(2 * id, l, mid);
  build(2 * id + 1, mid + 1, r);
  tr[id][0] = merge(tr[2 * id][0], tr[2 * id + 1][0]);
  tr[id][1] = merge(tr[2 * id][1], tr[2 * id + 1][1]);
}
void udt(int x, int y, int id = 1, int l = 1, int r = n) {
  if (l > y or r < x) return;
  if (l >= x and r <= y) {
    lz[id] ^= 1;
    return;
  }
  int mid = (l + r) / 2;
  if (lz[id]) lz[2 * id] ^= 1, lz[2 * id + 1] ^= 1, lz[id] = 0;
  udt(x, y, 2 * id, l, mid);
  udt(x, y, 2 * id + 1, mid + 1, r);
  tr[id][0] = merge(tr[2 * id][lz[2 * id]], tr[2 * id + 1][lz[2 * id + 1]]);
  tr[id][1] =
      merge(tr[2 * id][lz[2 * id] ^ 1], tr[2 * id + 1][lz[2 * id + 1] ^ 1]);
}
node ask(int x, int y, int id = 1, int l = 1, int r = n) {
  if (l >= x and r <= y) return tr[id][lz[id]];
  int mid = (l + r) / 2;
  if (y <= mid) return ask(x, y, 2 * id, l, mid);
  if (x > mid) return ask(x, y, 2 * id + 1, mid + 1, r);
  return merge(ask(x, y, 2 * id, l, mid), ask(x, y, 2 * id + 1, mid + 1, r));
}
int32_t main() {
  ios::sync_with_stdio(0), cin.tie(0);
  cin >> n >> q >> st;
  st = '#' + st;
  build();
  while (q--) {
    int l, r;
    cin >> l >> r;
    udt(l, r);
    cout << ask(l, r).mx << '\n';
  }
}
