#include <bits/stdc++.h>
using namespace std;
using ll = long long;
class seg {
 private:
  char ldir, rdir;
  int llen, rlen;
  int ma;
  bool block;

 public:
  seg() { ma = -1; }
  seg(char x) {
    ldir = rdir = x;
    llen = rlen = 1;
    ma = 1;
    block = false;
  }
  static char opp(char d) {
    if (d == '<') return '>';
    return '<';
  }
  seg operator+(const seg& o) {
    if (ma == -1) return o;
    if (o.ma == -1) return *this;
    seg nseg;
    nseg.ldir = ldir;
    nseg.rdir = o.rdir;
    nseg.llen = llen;
    nseg.rlen = o.rlen;
    nseg.ma = max(ma, o.ma);
    nseg.block = block | o.block;
    if (rdir == '<' && o.ldir == '>')
      nseg.block = true;
    else {
      if (!block) nseg.llen += o.llen;
      if (!o.block) nseg.rlen += rlen;
      nseg.ma = max(nseg.ma, rlen + o.llen);
    }
    return nseg;
  }
  int get_ma() { return ma; }
};
int n, q;
string s;
vector<pair<seg, seg> > t;
vector<bool> u;
void build(int v, int tl, int tr) {
  if (tl == tr)
    t[v] = make_pair(s[tl], seg::opp(s[tl]));
  else {
    int tm = (tl + tr) >> 1;
    build(v << 1, tl, tm);
    build((v << 1) + 1, tm + 1, tr);
    t[v] = make_pair(t[v << 1].first + t[(v << 1) + 1].first,
                     t[v << 1].second + t[(v << 1) + 1].second);
  }
}
void push(int v, int tl, int tr) {
  if (u[v]) {
    swap(t[v].first, t[v].second);
    u[v] = false;
    if (tl < tr) {
      u[v << 1] = !u[v << 1];
      u[(v << 1) + 1] = !u[(v << 1) + 1];
    }
  }
}
void opp(int v, int tl, int tr, int l, int r) {
  if (l > r) return;
  push(v, tl, tr);
  if (tl > r || l > tr) return;
  if (l <= tl && tr <= r) {
    u[v] = !u[v];
    push(v, tl, tr);
    return;
  }
  int tm = (tl + tr) >> 1;
  opp(v << 1, tl, tm, l, r);
  opp((v << 1) + 1, tm + 1, tr, l, r);
  t[v] = make_pair(t[v << 1].first + t[(v << 1) + 1].first,
                   t[v << 1].second + t[(v << 1) + 1].second);
}
seg cs(int v, int tl, int tr, int l, int r) {
  if (l > r) return seg();
  push(v, tl, tr);
  if (l > tr || tl > r) return seg();
  if (l <= tl && tr <= r) return t[v].first;
  int tm = (tl + tr) >> 1;
  return cs(v << 1, tl, tm, l, r) + cs((v << 1) + 1, tm + 1, tr, l, r);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin >> n >> q >> s;
  t.assign(4 * n + 10, make_pair(seg(), seg()));
  build(1, 0, n - 1);
  u.assign(4 * n + 10, false);
  while (q--) {
    int l, r;
    cin >> l >> r;
    l--;
    r--;
    opp(1, 0, n - 1, l, r);
    cout << cs(1, 0, n - 1, l, r).get_ma() << '\n';
  }
  return 0;
}
