#include <bits/stdc++.h>
using namespace std;
template <typename T>
void out(T x) {
  cout << x << endl;
  exit(0);
}
using ll = long long;
const ll mod = 1e9 + 7;
const int maxn = 1e6 + 5;
const int inf = 1e9;
int n, q;
string s;
char Flip(char c) {
  if (c == '>')
    c = '<';
  else
    c = '>';
  return c;
}
void better(int &x, int y) { x = max(x, y); }
int brute(int l, int r, bool flag) {
  if (flag) {
    for (int i = l; i <= r; i++) {
      s[i] = Flip(s[i]);
    }
  }
  vector<int> v(n + 2, 0);
  for (int i = l; i <= r; i++) {
    int x = i;
    while (true) {
      if (s[x] == '<') {
        if (x == 1 || s[x - 1] == '>') {
          v[x - 1]++;
          break;
        } else {
          x--;
        }
      }
      if (s[x] == '>') {
        if (x == n || s[x + 1] == '<') {
          v[x]++;
          break;
        } else {
          x++;
        }
      }
    }
  }
  return *max_element(v.begin(), v.end());
}
struct dat {
  int len;
  int res;
  int pref0, pref1;
  int suf0, suf1;
  int sinkl;
  int sinkr;
  dat() { len = res = pref0 = pref1 = suf0 = suf1 = sinkl = sinkr = 0; }
  dat(char c) {
    len = res = pref0 = pref1 = suf0 = suf1 = sinkl = sinkr = 0;
    len = 1;
    res = 1;
    if (c == '<') {
      pref0 = suf0 = 1;
    } else {
      pref1 = suf1 = 1;
    }
  }
};
dat merge(dat a, dat b) {
  dat x;
  x.len = a.len + b.len;
  if (a.len == a.pref0) {
    x.pref0 = a.len + b.pref0;
  } else {
    x.pref0 = a.pref0;
  }
  if (a.len == a.pref1) {
    x.pref1 = a.len + b.pref1;
  } else {
    x.pref1 = a.pref1;
  }
  if (b.len == b.suf0) {
    x.suf0 = a.suf0 + b.suf0;
  } else {
    x.suf0 = b.suf0;
  }
  if (b.len == b.suf1) {
    x.suf1 = a.suf1 + b.suf1;
  } else {
    x.suf1 = b.suf1;
  }
  x.sinkl = a.sinkl;
  if (a.len == a.pref1) better(x.sinkl, a.pref1 + b.pref0);
  if (a.len == a.pref1) better(x.sinkl, a.pref1 + b.sinkl);
  if (a.len == a.sinkl) better(x.sinkl, a.sinkl + b.pref0);
  x.sinkr = b.sinkr;
  if (b.len == b.pref0) better(x.sinkr, a.suf1 + b.pref0);
  if (b.len == b.sinkr) better(x.sinkr, a.suf1 + b.sinkr);
  if (b.len == b.suf0) better(x.sinkr, a.sinkr + b.suf0);
  x.res =
      max({a.res, b.res, x.pref0, x.pref1, x.suf0, x.suf1, x.sinkl, x.sinkr});
  better(x.res, a.suf1 + b.pref0);
  better(x.res, a.sinkr + b.pref0);
  better(x.res, a.suf1 + b.sinkl);
  return x;
}
struct node {
  dat v[2];
  node() { v[0] = v[1] = dat(); }
  node(char c) {
    v[0] = dat(c);
    v[1] = dat(Flip(c));
  }
  void flip() { swap(v[0], v[1]); }
};
node merge(node a, node b) {
  node x;
  for (int i = 0; i < 2; i++) {
    x.v[i] = merge(a.v[i], b.v[i]);
  }
  return x;
}
node t[4 * maxn];
bool o[4 * maxn];
void build(int v, int tl, int tr) {
  if (tl == tr) {
    t[v] = node(s[tl]);
  } else {
    int tm = (tl + tr) / 2;
    build(2 * v, tl, tm);
    build(2 * v + 1, tm + 1, tr);
    t[v] = merge(t[2 * v], t[2 * v + 1]);
  }
}
void push(int v) {
  if (!o[v]) return;
  t[2 * v].flip();
  t[2 * v + 1].flip();
  o[2 * v] = !o[2 * v];
  o[2 * v + 1] = !o[2 * v + 1];
  o[v] = false;
}
node qry(int v, int tl, int tr, int l, int r) {
  if (l > tr || r < tl) {
    return node();
  }
  if (l <= tl && tr <= r) {
    return t[v];
  }
  push(v);
  int tm = (tl + tr) / 2;
  return merge(qry(2 * v, tl, tm, l, r), qry(2 * v + 1, tm + 1, tr, l, r));
}
void flip(int v, int tl, int tr, int l, int r) {
  if (l > tr || r < tl) {
    return;
  }
  if (l <= tl && tr <= r) {
    t[v].flip();
    o[v] = !o[v];
    return;
  }
  push(v);
  int tm = (tl + tr) / 2;
  flip(2 * v, tl, tm, l, r);
  flip(2 * v + 1, tm + 1, tr, l, r);
  t[v] = merge(t[2 * v], t[2 * v + 1]);
}
const bool test = false;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> q;
  cin >> s;
  s = "." + s;
  build(1, 1, n);
  if (test) {
    for (int i = 1; i <= n; i++) {
      for (int j = i; j <= n; j++) {
        int q = qry(1, 1, n, i, j).v[0].res;
        int b = brute(i, j, false);
        assert(q == b);
      }
    }
    cout << "passed initial test" << endl;
  }
  while (q--) {
    int l, r;
    cin >> l >> r;
    flip(1, 1, n, l, r);
    int q = qry(1, 1, n, l, r).v[0].res;
    if (test) {
      int b = brute(l, r, true);
      cout << b << " was: " << q << endl;
      assert(q == b);
    }
    cout << q << "\n";
  }
  return 0;
}
