#include <bits/stdc++.h>
using namespace std;
int N, Q;
string s;
struct Info {
  int len;
  int l_len, r_len;
  char left, right;
  int ans;
  void Output() {
    printf("len=%d l_len=%d r_len=%d left=\'%c\' right=\'%c\' ans=%d\n", len,
           l_len, r_len, left, right, ans);
  }
};
class TreeNode {
 public:
  TreeNode *lch, *rch;
  int l, r;
  bool tag;
  Info front, back;
  TreeNode(int l, int r) : l(l), r(r) { tag = false; }
  void TurnOver() {
    tag = !tag;
    swap(front, back);
  }
  void PushDown() {
    if (tag) {
      tag = false;
      lch->TurnOver();
      rch->TurnOver();
    }
  }
  void Update() {
    front = Merge(lch->front, rch->front);
    back = Merge(lch->back, rch->back);
  }
  void Output() {
    printf("l: %d  r: %d  tag: %s\n", l, r, tag ? "true" : "false");
    printf("front: ");
    front.Output();
    printf("back: ");
    back.Output();
  }
  static Info Merge(const Info& a, const Info& b) {
    Info now;
    now.len = a.len + b.len;
    now.left = a.left;
    now.right = b.right;
    now.ans = max(a.ans, b.ans);
    if ((a.right == '<' && b.left == '<') ||
        (a.right == '>' && b.left == '>') ||
        (a.right == '>' && b.left == '<')) {
      if (a.r_len == a.len) {
        now.l_len = a.len + b.l_len;
      } else {
        now.l_len = a.l_len;
      }
      if (b.l_len == b.len) {
        now.r_len = b.len + a.r_len;
      } else {
        now.r_len = b.r_len;
      }
      now.ans = max(now.ans, a.r_len + b.l_len);
    } else {
      now.l_len = a.l_len;
      now.r_len = b.r_len;
    }
    return now;
  }
};
TreeNode* BuildTree(const string& s, int l, int r) {
  auto v = new TreeNode(l, r);
  if (l == r) {
    v->front.len = 1;
    v->front.l_len = v->front.r_len = 1;
    v->front.left = v->front.right = '<';
    v->front.ans = 1;
    v->back.len = 1;
    v->back.l_len = v->back.r_len = 1;
    v->back.left = v->back.right = '>';
    v->back.ans = 1;
    if (s[l] == '>') swap(v->front, v->back);
    return v;
  }
  int mid = (l + r) / 2;
  v->lch = BuildTree(s, l, mid);
  v->rch = BuildTree(s, mid + 1, r);
  v->Update();
  return v;
}
void Change(TreeNode* v, int ww, int ee, vector<TreeNode*>& visit) {
  if (ww <= v->l && v->r <= ee) {
    v->TurnOver();
    visit.push_back(v);
    return;
  }
  v->PushDown();
  int mid = (v->l + v->r) / 2;
  if (ww <= mid) Change(v->lch, ww, ee, visit);
  if (ee > mid) Change(v->rch, ww, ee, visit);
  v->Update();
}
int main() {
  cin >> N >> Q;
  cin >> s;
  auto root = BuildTree(s, 0, N - 1);
  vector<TreeNode*> visit;
  for (int i = 0; i < Q; i++) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    visit.clear();
    Change(root, a, b, visit);
    Info info = visit[0]->front;
    for (int i = 1; i < visit.size(); i++) {
      info = TreeNode::Merge(info, visit[i]->front);
    }
    cout << info.ans << endl;
  }
  return 0;
}
