#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
const long long INF = 0x3f3f3f3f3f3f3f3f;
const long long llinf = (1LL << 60);
const int inf = (1 << 30);
const int nmax = 5e5 + 50;
const long long mod = 1e9 + 7;
using namespace std;
int n, q, l, r, i;
char c[nmax];
struct nod {
  int x00, x01, x10, x11, mx1, mx2, rs, l, t, y00, y01, y10, y11;
  nod() {
    this->x00 = this->x01 = this->x10 = this->x11 = this->y00 = this->y01 =
        this->y10 = this->y11 = this->mx1 = this->mx2 = this->rs = this->l =
            this->t = 0;
  }
} st[4 * nmax], f, s, e;
nod merge(nod x, nod y) {
  if (!x.t) return y;
  if (!y.t) return x;
  nod z = e;
  z.t = x.t + y.t;
  z.x00 = x.x00, z.x01 = x.x01, z.x10 = y.x10, z.x11 = y.x11;
  z.y00 = x.y00, z.y01 = x.y01, z.y10 = y.y10, z.y11 = y.y11;
  if (x.x00 == x.t) z.x00 += y.x00;
  if (x.x01 == x.t) z.x01 += y.x01;
  if (y.x10 == y.t) z.x10 += x.x10;
  if (y.x11 == y.t) z.x11 += x.x11;
  z.rs = max(x.rs, y.rs);
  z.rs = max(max(z.x00, z.x01), max(z.x10, z.x11));
  z.rs = max(z.rs, max(x.x10 + y.x00, x.x11 + y.x01));
  z.mx1 = max(x.mx1, y.mx1), z.mx2 = max(x.mx2, y.mx2);
  if (x.y00 == x.t)
    z.y00 += y.x01;
  else if (x.x00 == x.t && (y.x01 || y.y00))
    z.y00 = x.x00 + max(y.x01, y.y00);
  if (x.y01 == x.t)
    z.y01 += y.x00;
  else if (x.x01 == x.t && (y.x00 || y.y01))
    z.y01 = x.x01 + max(y.x00, y.y01);
  if (y.y10 == y.t)
    z.y10 += x.x10;
  else if (y.x11 == y.t && (x.x10 || x.y10))
    z.y10 = y.x11 + max(x.x10, x.y10);
  if (y.y11 == y.t)
    z.y11 += x.x11;
  else if (y.x10 == y.t && (x.x11 || x.y11))
    z.y11 = y.x10 + max(x.x11, x.y11);
  if (x.y10) z.mx1 = max(z.mx1, x.y10 + y.x01);
  if (y.y00) z.mx1 = max(z.mx1, y.y00 + x.x10);
  if (x.y11) z.mx2 = max(z.mx2, x.y11 + y.x00);
  if (y.y01) z.mx2 = max(z.mx2, y.y01 + x.x11);
  z.mx1 = max(z.mx1, max(z.y00, z.y10));
  z.mx2 = max(z.mx2, max(z.y01, z.y11));
  if (x.x10 && y.x01) z.mx1 = max(z.mx1, x.x10 + y.x01);
  if (x.x11 && y.x00) z.mx2 = max(z.mx2, x.x11 + y.x00);
  return z;
}
void build(int x, int l, int r) {
  if (l == r) {
    if (c[l] == '>')
      st[x] = f;
    else
      st[x] = s;
    return;
  }
  int mid = (l + r) / 2;
  build(2 * x, l, mid);
  build(2 * x + 1, mid + 1, r);
  st[x] = merge(st[2 * x], st[2 * x + 1]);
}
void push(int x, int l, int r) {
  if (!st[x].l) return;
  swap(st[x].x00, st[x].x01), swap(st[x].y00, st[x].y01),
      swap(st[x].x10, st[x].x11), swap(st[x].y10, st[x].y11),
      swap(st[x].mx1, st[x].mx2);
  if (l != r) {
    st[2 * x].l ^= 1;
    st[2 * x + 1].l ^= 1;
  }
  st[x].l = 0;
}
void upd(int x, int l, int r, int tl, int tr) {
  push(x, l, r);
  if (tl <= l && r <= tr) {
    st[x].l ^= 1;
    push(x, l, r);
    return;
  }
  int mid = (l + r) / 2;
  if (tl <= mid) upd(x * 2, l, mid, tl, tr);
  if (mid < tr) upd(x * 2 + 1, mid + 1, r, tl, tr);
  push(x * 2, l, mid);
  push(x * 2 + 1, mid + 1, r);
  st[x] = merge(st[x * 2], st[x * 2 + 1]);
}
nod qry(int x, int l, int r, int tl, int tr) {
  push(x, l, r);
  if (l > tr || r < tl) return e;
  if (tl <= l && r <= tr) return st[x];
  int mid = (l + r) / 2;
  return merge(qry(x * 2, l, mid, tl, tr), qry(x * 2 + 1, mid + 1, r, tl, tr));
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cerr.tie(0);
  cout.tie(0);
  cin >> n >> q;
  for (i = 1; i <= n; i++) cin >> c[i];
  f.x00 = f.x10 = s.x01 = s.x11 = f.rs = s.rs = f.t = s.t = 1;
  build(1, 1, n);
  while (q--) {
    cin >> l >> r;
    upd(1, 1, n, l, r);
    nod o = qry(1, 1, n, l, r);
    cout << max(o.rs, o.mx1) << '\n';
  }
  return 0;
}
