#include <bits/stdc++.h>
using namespace std;
const int N = 5e5 + 5;
struct node {
  int pref[2][2];
  int suf[2][2];
  int ans[2];
  int size;
  node() {
    for (int i : {0, 1}) {
      for (int j : {0, 1}) {
        pref[i][j] = suf[i][j] = 0;
      }
    }
    ans[0] = ans[1] = 1;
    size = 0;
  }
};
node t[N << 2];
bool d[N << 2];
void upd(int v) {
  swap(t[v].pref[0], t[v].pref[1]);
  swap(t[v].suf[0], t[v].suf[1]);
  swap(t[v].ans[0], t[v].ans[1]);
  d[v] ^= 1;
}
void push(int v) {
  if (d[v]) {
    upd(v + v + 1);
    upd(v + v + 2);
    d[v] = 0;
  }
}
node unite(node lc, node rc) {
  if (lc.size == 0) {
    return rc;
  }
  if (rc.size == 0) {
    return lc;
  }
  node res;
  res.size = lc.size + rc.size;
  for (int c : {0, 1}) {
    auto lp = lc.pref[c], ls = lc.suf[c];
    auto rp = rc.pref[c], rs = rc.suf[c];
    auto &ep = res.pref[c], &es = res.suf[c];
    ep[0] = lp[0];
    if (ep[0] == lc.size) {
      ep[0] += rp[0];
    }
    ep[1] = lp[1];
    if (ep[1] == lc.size) {
      ep[1] += rp[0];
    }
    if (ls[0] == lc.size && rp[1] != 0) {
      ep[1] = max(ep[1], lc.size + rp[1]);
    }
    if (ls[0] == lc.size && rp[0] != 0) {
      ep[1] = max(ep[1], lc.size + rp[0]);
    }
    es[0] = rs[0];
    if (es[0] == rc.size) {
      es[0] += ls[0];
    }
    es[1] = rs[1];
    if (es[1] == rc.size) {
      es[1] += ls[0];
    }
    if (rp[0] == rc.size && ls[1] != 0) {
      es[1] = max(es[1], rc.size + ls[1]);
    }
    if (rp[0] == rc.size && ls[0] != 0) {
      es[1] = max(es[1], rc.size + ls[0]);
    }
    res.ans[c] = max(lc.ans[c], rc.ans[c]);
    res.ans[c] = max(res.ans[c], ls[0] + rp[0]);
    res.ans[c] = max(res.ans[c], ls[0] + rp[1]);
    res.ans[c] = max(res.ans[c], ls[1] + rp[0]);
    if (lp[0] == lc.size) {
      res.ans[c] = max(res.ans[c], lc.size + rp[0]);
    }
    if (rs[0] == rc.size) {
      res.ans[c] = max(res.ans[c], rc.size + ls[0]);
    }
  }
  return res;
}
inline void pull(int v) { t[v] = unite(t[v + v + 1], t[v + v + 2]); }
int n;
string s;
void build(int v = 0, int tl = 0, int tr = n) {
  if (tr - tl == 1) {
    t[v].size = tr - tl;
    t[v].pref[0][0] = s[tl] == '<';
    t[v].pref[1][0] = s[tl] == '>';
    t[v].suf[0][0] = s[tl] == '>';
    t[v].suf[1][0] = s[tl] == '<';
    return;
  }
  int tm = (tl + tr) / 2;
  build(v + v + 1, tl, tm);
  build(v + v + 2, tm, tr);
  pull(v);
}
void upd(int l, int r, int v = 0, int tl = 0, int tr = n) {
  if (r <= tl || tr <= l) {
    return;
  }
  if (l <= tl && tr <= r) {
    return upd(v);
  }
  push(v);
  int tm = (tl + tr) / 2;
  upd(l, r, v + v + 1, tl, tm);
  upd(l, r, v + v + 2, tm, tr);
  pull(v);
}
node get(int l, int r, int v = 0, int tl = 0, int tr = n) {
  if (r <= tl || tr <= l) {
    return node();
  }
  if (l <= tl && tr <= r) {
    return t[v];
  }
  push(v);
  int tm = (tl + tr) / 2;
  return unite(get(l, r, v + v + 1, tl, tm), get(l, r, v + v + 2, tm, tr));
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int q;
  cin >> n >> q >> s;
  build();
  while (q--) {
    int l, r;
    cin >> l >> r;
    --l;
    upd(l, r);
    cout << get(l, r).ans[0] << '\n';
  }
  return 0;
}
