#include <bits/stdc++.h>
using namespace std;
struct node {
  int prefix_plus, suffix_minus, prefix_plus_minus, suffix_minus_plus,
      best_plus_minus;
  int prefix_minus, suffix_plus, prefix_minus_plus, suffix_plus_minus,
      best_minus_plus;
  int length, is_lazy;
  node() {
    length = 0;
    is_lazy = false;
    prefix_plus = prefix_minus = suffix_plus = suffix_minus = 0;
    prefix_plus_minus = prefix_minus_plus = suffix_minus_plus =
        suffix_plus_minus = 0;
    best_minus_plus = best_plus_minus = 0;
  };
  node(char ch) {
    switch (ch) {
      case '<': {
        prefix_plus = 1;
        suffix_plus = 1;
        prefix_minus = 0;
        suffix_minus = 0;
        break;
      }
      case '>': {
        prefix_minus = 1;
        suffix_minus = 1;
        prefix_plus = 0;
        suffix_plus = 0;
        break;
      }
    }
    is_lazy = false;
    length = 1;
    prefix_plus_minus = prefix_minus_plus = suffix_minus_plus =
        suffix_plus_minus = 0;
    best_minus_plus = best_plus_minus = 0;
  }
};
const int MAX_N = 5e5 + 5;
node tree[3 * MAX_N];
string S;
void print(node n) {
  cout << "Length = " << n.length << "\n";
  cout << "PREFIX :\n";
  cout << "< = " << n.prefix_plus << " > = " << n.prefix_minus
       << " <> = " << n.prefix_plus_minus << " >< " << n.prefix_minus_plus
       << "\n";
  cout << "suffix :\n";
  cout << "< = " << n.suffix_plus << " > = " << n.suffix_minus
       << " <> = " << n.suffix_plus_minus << " >< " << n.suffix_minus_plus
       << "\n";
  cout << "BEST\n";
  cout << " >< " << n.best_minus_plus << " <> " << n.best_plus_minus << "\n";
}
void flip_flag(int &n) { n = !(n); }
void flip(int n) {
  swap(tree[n].prefix_plus, tree[n].prefix_minus);
  swap(tree[n].suffix_minus, tree[n].suffix_plus);
  swap(tree[n].prefix_plus_minus, tree[n].prefix_minus_plus);
  swap(tree[n].suffix_plus_minus, tree[n].suffix_minus_plus);
  swap(tree[n].best_plus_minus, tree[n].best_minus_plus);
}
void merge(node &L, node &R, node &answer) {
  if (L.length == 0) {
    answer = R;
    return;
  }
  if (R.length == 0) {
    answer = L;
    return;
  }
  answer.length = L.length + R.length;
  answer.prefix_plus =
      L.prefix_plus + (L.prefix_plus == L.length ? R.prefix_plus : 0);
  answer.prefix_minus =
      L.prefix_minus + (L.prefix_minus == L.length ? R.prefix_minus : 0);
  answer.suffix_plus =
      R.suffix_plus + (R.suffix_plus == R.length ? L.suffix_plus : 0);
  answer.suffix_minus =
      R.suffix_minus + (R.suffix_minus == R.length ? L.suffix_minus : 0);
  answer.prefix_plus_minus = L.prefix_plus_minus;
  if (L.prefix_plus_minus == L.length) {
    answer.prefix_plus_minus += R.prefix_minus;
  }
  if (L.prefix_plus == L.length) {
    if (R.prefix_minus != 0) {
      answer.prefix_plus_minus =
          max(answer.prefix_plus_minus, L.prefix_plus + R.prefix_minus);
    }
    if (R.prefix_plus_minus != 0) {
      answer.prefix_plus_minus =
          max(answer.prefix_plus_minus, L.prefix_plus + R.prefix_plus_minus);
    }
  }
  answer.prefix_minus_plus = L.prefix_minus_plus;
  if (L.prefix_minus_plus == L.length) {
    answer.prefix_minus_plus += R.prefix_plus;
  }
  if (L.prefix_minus == L.length) {
    if (R.prefix_plus != 0) {
      answer.prefix_minus_plus =
          max(answer.prefix_minus_plus, L.prefix_minus + R.prefix_plus);
    }
    if (R.prefix_minus_plus != 0) {
      answer.prefix_minus_plus =
          max(answer.prefix_minus_plus, L.prefix_minus + R.prefix_minus_plus);
    }
  }
  answer.suffix_plus_minus = R.suffix_plus_minus;
  if (R.suffix_plus_minus == R.length) {
    answer.suffix_plus_minus += L.suffix_plus;
  }
  if (R.suffix_minus == R.length) {
    if (L.suffix_plus != 0) {
      answer.suffix_plus_minus =
          max(answer.suffix_plus_minus, L.suffix_plus + R.suffix_minus);
    }
    if (L.suffix_plus_minus != 0) {
      answer.suffix_plus_minus =
          max(answer.suffix_plus_minus, L.suffix_plus_minus + R.suffix_minus);
    }
  }
  answer.suffix_minus_plus = R.suffix_minus_plus;
  if (R.suffix_minus_plus == R.length) {
    answer.suffix_minus_plus += L.suffix_minus;
  }
  if (R.suffix_plus == R.length) {
    if (L.suffix_minus != 0) {
      answer.suffix_minus_plus =
          max(answer.suffix_minus_plus, L.suffix_minus + R.suffix_plus);
    }
    if (L.suffix_minus_plus != 0) {
      answer.suffix_minus_plus =
          max(answer.suffix_minus_plus, L.suffix_minus_plus + R.suffix_plus);
    }
  }
  answer.best_plus_minus = max(L.best_plus_minus, R.best_plus_minus);
  answer.best_plus_minus = max(answer.best_plus_minus,
                               max(L.prefix_plus_minus, R.suffix_plus_minus));
  if (L.suffix_plus > 0 && R.prefix_minus > 0) {
    answer.best_plus_minus =
        max(answer.best_plus_minus, L.suffix_plus + R.prefix_minus);
  }
  if (L.suffix_plus_minus > 0) {
    answer.best_plus_minus =
        max(answer.best_plus_minus, L.suffix_plus_minus + R.prefix_minus);
  }
  if (R.prefix_plus_minus > 0) {
    answer.best_plus_minus =
        max(answer.best_plus_minus, L.suffix_plus + R.prefix_plus_minus);
  }
  answer.best_minus_plus = max(L.best_minus_plus, R.best_minus_plus);
  answer.best_minus_plus = max(answer.best_minus_plus,
                               max(L.prefix_minus_plus, R.suffix_minus_plus));
  if (L.suffix_minus > 0 && R.prefix_plus > 0) {
    answer.best_minus_plus =
        max(answer.best_minus_plus, L.suffix_minus + R.prefix_plus);
  }
  if (L.suffix_minus_plus > 0) {
    answer.best_minus_plus =
        max(answer.best_minus_plus, L.suffix_minus_plus + R.prefix_plus);
  }
  if (R.prefix_minus_plus > 0) {
    answer.best_minus_plus =
        max(answer.best_minus_plus, L.suffix_minus + R.prefix_minus_plus);
  }
}
void propagate(int n, int left, int right) {
  if (tree[n].is_lazy == false) {
    return;
  }
  flip(n);
  if (left != right) {
    flip_flag(tree[(2 * n)].is_lazy);
    flip_flag(tree[(2 * n + 1)].is_lazy);
  }
  tree[n].is_lazy = false;
}
void build(int n, int left, int right) {
  if (left == right) {
    tree[n] = node(S[left - 1]);
    return;
  }
  int mid = (left + right) / 2;
  build((2 * n), left, mid);
  build((2 * n + 1), mid + 1, right);
  merge(tree[(2 * n)], tree[(2 * n + 1)], tree[n]);
}
void update(int n, int left, int right, int query_left, int query_right) {
  propagate(n, left, right);
  if (query_right < left || right < query_left) {
    return;
  }
  if (query_left <= left && right <= query_right) {
    flip_flag(tree[n].is_lazy);
    propagate(n, left, right);
    return;
  }
  int mid = (left + right) / 2;
  update((2 * n), left, mid, query_left, query_right);
  update((2 * n + 1), mid + 1, right, query_left, query_right);
  merge(tree[(2 * n)], tree[(2 * n + 1)], tree[n]);
}
node get_answer(int n, int left, int right, int query_left, int query_right) {
  propagate(n, left, right);
  if (query_right < left || right < query_left) {
    return node();
  }
  if (query_left <= left && right <= query_right) {
    return tree[n];
  }
  int mid = (left + right) / 2;
  node L = get_answer((2 * n), left, mid, query_left, query_right);
  node R = get_answer((2 * n + 1), mid + 1, right, query_left, query_right);
  node answer;
  merge(L, R, answer);
  return answer;
}
int main() {
  int length, no_of_queries;
  cin >> length >> no_of_queries;
  cin >> S;
  build(1, 1, length);
  for (int i = 1; i <= no_of_queries; i++) {
    int left, right;
    cin >> left >> right;
    update(1, 1, length, left, right);
    node answer = get_answer(1, 1, length, left, right);
    int best_answer = max(answer.prefix_plus,
                          max(answer.best_minus_plus, answer.suffix_minus));
    cout << best_answer << "\n";
  }
  return 0;
}
