#include <bits/stdc++.h>
using namespace std;
int n, Q, Ans;
int a[500005], L[500005 << 2][4], R[500005 << 2][4], _1[500005 << 2],
    _0[500005 << 2], mx[500005 << 2], c[500005 << 2], bl[4], br[4];
char ch[500005];
void update(int v, int l, int r) {
  int mid = (l + r) >> 1;
  L[v][0] = L[v << 1][0];
  L[v][1] = L[v << 1][1];
  L[v][2] = L[v << 1][2];
  L[v][3] = L[v << 1][3];
  R[v][0] = R[v << 1 | 1][0];
  R[v][1] = R[v << 1 | 1][1];
  R[v][2] = R[v << 1 | 1][2];
  R[v][3] = R[v << 1 | 1][3];
  if (L[v << 1][0] == (mid - l + 1)) {
    L[v][0] += L[v << 1 | 1][0];
    if (L[v << 1 | 1][1]) L[v][2] = L[v << 1][0] + L[v << 1 | 1][1];
    if (L[v << 1 | 1][2]) L[v][2] = L[v << 1][0] + L[v << 1 | 1][2];
  }
  if (L[v << 1][1] == (mid - l + 1)) {
    L[v][1] += L[v << 1 | 1][1];
    if (L[v << 1 | 1][0]) L[v][3] = L[v << 1][1] + L[v << 1 | 1][0];
    if (L[v << 1 | 1][3]) L[v][3] = L[v << 1][1] + L[v << 1 | 1][3];
  }
  if (L[v << 1][2] == (mid - l + 1)) L[v][2] += L[v << 1 | 1][1];
  if (L[v << 1][3] == (mid - l + 1)) L[v][3] += L[v << 1 | 1][0];
  if (R[v << 1 | 1][0] == (r - mid)) {
    R[v][0] += R[v << 1][0];
    if (R[v << 1][1]) R[v][2] = R[v << 1][1] + R[v << 1 | 1][0];
    if (R[v << 1][2]) R[v][2] = R[v << 1][2] + R[v << 1 | 1][0];
  }
  if (R[v << 1 | 1][1] == (r - mid)) {
    R[v][1] += R[v << 1][1];
    if (R[v << 1][0]) R[v][3] = R[v << 1][0] + R[v << 1 | 1][1];
    if (R[v << 1][3]) R[v][3] = R[v << 1][3] + R[v << 1 | 1][1];
  }
  if (R[v << 1 | 1][2] == (r - mid)) R[v][2] += R[v << 1][1];
  if (R[v << 1 | 1][3] == (r - mid)) R[v][3] += R[v << 1][0];
  _1[v] = max(_1[v << 1], _1[v << 1 | 1]);
  _0[v] = max(_0[v << 1], _0[v << 1 | 1]);
  if (R[v << 1][0] && L[v << 1 | 1][1])
    _1[v] = max(_1[v], R[v << 1][0] + L[v << 1 | 1][1]);
  if (R[v << 1][0] && L[v << 1 | 1][2])
    _1[v] = max(_1[v], R[v << 1][0] + L[v << 1 | 1][2]);
  if (R[v << 1][3] && L[v << 1 | 1][1])
    _1[v] = max(_1[v], R[v << 1][3] + L[v << 1 | 1][1]);
  if (R[v << 1][1] && L[v << 1 | 1][0])
    _0[v] = max(_0[v], R[v << 1][1] + L[v << 1 | 1][0]);
  if (R[v << 1][2] && L[v << 1 | 1][0])
    _0[v] = max(_0[v], R[v << 1][2] + L[v << 1 | 1][0]);
  if (R[v << 1][1] && L[v << 1 | 1][3])
    _0[v] = max(_0[v], R[v << 1][1] + L[v << 1 | 1][3]);
  mx[v] = max(_0[v], max(L[v][0], R[v][1]));
}
void build(int v, int l, int r) {
  int i, j, mid = (l + r) >> 1;
  c[v] = 1;
  if (l == r) {
    if (a[l])
      L[v][1] = R[v][1] = 1;
    else
      L[v][0] = R[v][0] = 1;
    mx[v] = 1;
    return;
  }
  build(v << 1, l, mid);
  build(v << 1 | 1, mid + 1, r);
  update(v, l, r);
}
void pushdown(int v) {
  if (c[v] == -1) {
    c[v << 1] *= -1;
    c[v << 1 | 1] *= -1;
    swap(L[v << 1][0], L[v << 1][1]);
    swap(L[v << 1][2], L[v << 1][3]);
    swap(R[v << 1][0], R[v << 1][1]);
    swap(R[v << 1][2], R[v << 1][3]);
    swap(_1[v << 1], _0[v << 1]);
    mx[v << 1] = max(_0[v << 1], max(L[v << 1][0], R[v << 1][1]));
    swap(L[v << 1 | 1][0], L[v << 1 | 1][1]);
    swap(L[v << 1 | 1][2], L[v << 1 | 1][3]);
    swap(R[v << 1 | 1][0], R[v << 1 | 1][1]);
    swap(R[v << 1 | 1][2], R[v << 1 | 1][3]);
    swap(_1[v << 1 | 1], _0[v << 1 | 1]);
    mx[v << 1 | 1] =
        max(_0[v << 1 | 1], max(L[v << 1 | 1][0], R[v << 1 | 1][1]));
    c[v] = 1;
  }
}
void Modify(int v, int l, int r, int x, int y) {
  int i, j, mid = (l + r) >> 1;
  if (x <= l && r <= y) {
    c[v] *= -1;
    swap(L[v][0], L[v][1]);
    swap(L[v][2], L[v][3]);
    swap(R[v][0], R[v][1]);
    swap(R[v][2], R[v][3]);
    swap(_1[v], _0[v]);
    mx[v] = max(_0[v], max(L[v][0], R[v][1]));
    return;
  }
  pushdown(v);
  if (x <= mid) Modify(v << 1, l, mid, x, y);
  if (y > mid) Modify(v << 1 | 1, mid + 1, r, x, y);
  update(v, l, r);
}
void Query(int v, int l, int r, int x, int y) {
  int i, j, mid = (l + r) >> 1;
  int L1[4], R1[4], L2[4], R2[4];
  if (x <= l && r <= y) {
    Ans = max(Ans, mx[v]);
    bl[0] = L[v][0], bl[1] = L[v][1], bl[2] = L[v][2], bl[3] = L[v][3];
    br[0] = R[v][0], br[1] = R[v][1], br[2] = R[v][2], br[3] = R[v][3];
    return;
  }
  pushdown(v);
  if (y <= mid)
    Query(v << 1, l, mid, x, y);
  else if (x > mid)
    Query(v << 1 | 1, mid + 1, r, x, y);
  else {
    Query(v << 1, l, mid, x, y);
    L1[0] = bl[0], L1[1] = bl[1], L1[2] = bl[2], L1[3] = bl[3];
    R1[0] = br[0], R1[1] = br[1], R1[2] = br[2], R1[3] = br[3];
    Query(v << 1 | 1, mid + 1, r, x, y);
    L2[0] = bl[0], L2[1] = bl[1], L2[2] = bl[2], L2[3] = bl[3];
    R2[0] = br[0], R2[1] = br[1], R2[2] = br[2], R2[3] = br[3];
    bl[0] = L1[0], bl[1] = L1[1], bl[2] = L1[2], bl[3] = L1[3];
    br[0] = R2[0], br[1] = R2[1], br[2] = R2[2], br[3] = R2[3];
    if (L1[0] == (mid - max(x, l) + 1)) {
      bl[0] += L2[0];
      if (L2[1]) bl[2] = L1[0] + L2[1];
      if (L2[2]) bl[2] = L1[0] + L2[2];
    }
    if (L1[1] == (mid - max(x, l) + 1)) {
      bl[1] += L2[1];
      if (L2[0]) bl[3] = L1[1] + L2[0];
      if (L2[3]) bl[3] = L1[1] + L2[3];
    }
    if (L1[2] == (mid - max(x, l) + 1)) bl[2] += L2[1];
    if (L1[3] == (mid - max(x, l) + 1)) bl[3] += L2[0];
    if (R2[0] == (min(r, y) - mid)) {
      br[0] += R1[0];
      if (R1[1]) br[2] = R2[0] + R1[1];
      if (R1[2]) br[2] = R2[0] + R1[2];
    }
    if (R2[1] == (min(r, y) - mid)) {
      br[1] += R1[1];
      if (R2[0]) br[3] = R2[1] + R2[0];
      if (R2[3]) br[3] = R2[1] + R2[3];
    }
    if (R2[2] == (min(r, y) - mid)) br[2] += R1[1];
    if (R2[3] == (min(r, y) - mid)) br[3] += R1[0];
    Ans = max(
        Ans,
        max(bl[0], max(br[1], max(R1[1] + max(L2[0], L2[3]), L2[0] + R1[2]))));
  }
}
int main() {
  scanf("%d%d", &n, &Q);
  scanf("%s", ch + 1);
  for (int i = 1; i <= n; i++) {
    if (ch[i] == '>')
      a[i] = 1;
    else
      a[i] = 0;
  }
  build(1, 1, n);
  while (Q--) {
    Ans = 0;
    int l, r;
    scanf("%d%d", &l, &r);
    Modify(1, 1, n, l, r);
    Query(1, 1, n, l, r);
    printf("%d\n", Ans);
  }
}
