#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC target("sse4")
using namespace std;
struct seg {
  int sz = 0;
  int closed = 0;
  int open = 0;
  int prel = 0;
  int prer = 0;
  int sufl = 0;
  int sufr = 0;
  int preop = 0;
  int precl = 0;
  int sufop = 0;
  int sufcl = 0;
  bool revc = 0;
};
seg mergeseg(seg a, seg b) {
  seg ans;
  ans.sz = a.sz + b.sz;
  ans.closed = max(a.closed, b.closed);
  ans.closed = max(ans.closed, a.sufcl + b.prel);
  ans.closed = max(ans.closed, a.sufr + b.precl);
  ans.closed = max(ans.closed, a.sufr + b.prel);
  ans.open = max(a.open, b.open);
  ans.open = max(ans.open, a.sufop + b.prer);
  ans.open = max(ans.open, a.sufl + b.preop);
  ans.open = max(ans.open, a.sufl + b.prer);
  ans.prel = a.prel;
  if (a.prel == a.sz) ans.prel += b.prel;
  ans.prer = a.prer;
  if (a.prer == a.sz) ans.prer += b.prer;
  ans.sufl = b.sufl;
  if (b.sufl == b.sz) ans.sufl += a.sufl;
  ans.sufr = b.sufr;
  if (b.sufr == b.sz) ans.sufr += a.sufr;
  ans.preop = a.preop;
  if (a.preop == a.sz) ans.preop += b.prer;
  if (a.sufl == a.sz) {
    ans.preop = max(ans.preop, a.sufl + b.preop);
    ans.preop = max(ans.preop, a.sufl + b.prer);
  }
  ans.precl = a.precl;
  if (a.precl == a.sz) ans.precl += b.prel;
  if (a.sufr == a.sz) {
    ans.precl = max(ans.precl, a.sufr + b.precl);
    ans.precl = max(ans.precl, a.sufr + b.prel);
  }
  ans.sufop = b.sufop;
  if (b.sufop == b.sz) ans.sufop += a.sufl;
  if (b.sufr == b.sz) {
    ans.sufop = max(ans.sufop, a.sufop + b.sufr);
    ans.sufop = max(ans.sufop, a.sufl + b.sufr);
  }
  ans.sufcl = b.sufcl;
  if (b.sufcl == b.sz) ans.sufcl += a.sufr;
  if (b.sufl == b.sz) {
    ans.sufcl = max(ans.sufcl, a.sufcl + b.sufl);
    ans.sufcl = max(ans.sufcl, a.sufr + b.sufl);
  }
  return ans;
}
void rev(seg &a) {
  a.revc = !a.revc;
  swap(a.closed, a.open);
  swap(a.precl, a.preop);
  swap(a.prel, a.prer);
  swap(a.sufcl, a.sufop);
  swap(a.sufl, a.sufr);
}
void create(seg &ans, bool gl) {
  ans.sz = 1;
  if (gl) {
    ans.prel = 1;
    ans.sufl = 1;
  } else {
    ans.prer = 1;
    ans.sufr = 1;
  }
}
int n;
const int large = 5e5 + 1;
seg segtree[4 * large];
void upd(int p, bool gl, int l = 1, int r = n, int pos = 0) {
  if (l == r) {
    create(segtree[pos], gl);
    return;
  }
  int mid = (l + r) / 2;
  if (p <= mid)
    upd(p, gl, l, mid, 2 * pos + 1);
  else
    upd(p, gl, mid + 1, r, 2 * pos + 2);
  segtree[pos] = mergeseg(segtree[2 * pos + 1], segtree[2 * pos + 2]);
}
seg rq(int l, int r, int rl = 1, int rr = n, int pos = 0) {
  if (l == rl && r == rr) return segtree[pos];
  if (segtree[pos].revc) {
    rev(segtree[2 * pos + 1]);
    rev(segtree[2 * pos + 2]);
    segtree[pos].revc = 0;
  }
  int mid = (rl + rr) / 2;
  if (r <= mid)
    return rq(l, r, rl, mid, 2 * pos + 1);
  else if (l > mid)
    return rq(l, r, mid + 1, rr, 2 * pos + 2);
  else
    return mergeseg(rq(l, mid, rl, mid, 2 * pos + 1),
                    rq(mid + 1, r, mid + 1, rr, 2 * pos + 2));
}
int query(int l, int r) {
  seg a = rq(l, r);
  return max(a.closed, max(a.prel, a.sufr));
}
void fl(int l, int r, int rl = 1, int rr = n, int pos = 0) {
  if (l == rl && r == rr) {
    rev(segtree[pos]);
    return;
  }
  if (segtree[pos].revc) {
    rev(segtree[2 * pos + 1]);
    rev(segtree[2 * pos + 2]);
    segtree[pos].revc = 0;
  }
  int mid = (rl + rr) / 2;
  if (r <= mid)
    fl(l, r, rl, mid, 2 * pos + 1);
  else if (l > mid)
    fl(l, r, mid + 1, rr, 2 * pos + 2);
  else {
    fl(l, mid, rl, mid, 2 * pos + 1);
    fl(mid + 1, r, mid + 1, rr, 2 * pos + 2);
  }
  segtree[pos] = mergeseg(segtree[2 * pos + 1], segtree[2 * pos + 2]);
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  memset(segtree, 0, sizeof(segtree));
  int q;
  cin >> n >> q;
  for (int i = 0; i < n; i++) {
    char a;
    cin >> a;
    if (a == '<')
      upd(i + 1, 1);
    else
      upd(i + 1, 0);
  }
  for (int i = 0; i < q; i++) {
    int l, r;
    cin >> l >> r;
    fl(l, r);
    cout << query(l, r) << "\n";
  }
  return 0;
}
