#include <bits/stdc++.h>
const int MAX_N = 500000;
struct SegTree {
  bool inverted;
  int size;
  int in[2][2];
  int pref[2][2];
  int suff[2][2];
};
char s[MAX_N + 1];
SegTree segTree[1 << 20];
SegTree join(SegTree left, SegTree right) {
  SegTree answer;
  answer.inverted = false;
  answer.size = left.size + right.size;
  for (int a : {0, 1}) {
    for (int b : {0, 1}) {
      answer.in[a][b] = std::max(left.in[a][b], right.in[a][b]);
      answer.pref[a][b] = left.pref[a][b];
      answer.suff[a][b] = right.suff[a][b];
    }
  }
  for (int a : {0, 1}) {
    for (int b : {0, 1}) {
      for (int c : {0, 1}) {
        for (int d : {0, 1}) {
          if ((a <= b && b <= c && c <= d) || (a >= b && b >= c && c >= d)) {
            answer.in[a][d] =
                std::max(answer.in[a][d], left.suff[a][b] + right.pref[c][d]);
            if (left.pref[a][b] == left.size) {
              answer.pref[a][d] = std::max(answer.pref[a][d],
                                           left.pref[a][b] + right.pref[c][d]);
            }
            if (right.suff[c][d] == right.size) {
              answer.suff[a][d] = std::max(answer.suff[a][d],
                                           left.suff[a][b] + right.suff[c][d]);
            }
          }
        }
      }
    }
  }
  return answer;
}
void invert(int index) {
  SegTree &root = segTree[index];
  root.inverted ^= 1;
  for (int a : {0, 1}) {
    std::swap(root.in[a][0], root.in[1 - a][1]);
    std::swap(root.pref[a][0], root.pref[1 - a][1]);
    std::swap(root.suff[a][0], root.suff[1 - a][1]);
  }
}
void propagate(int index) {
  if (segTree[index].inverted) {
    segTree[index].inverted = false;
    if (index < (1 << 19)) {
      invert(2 * index);
      invert(2 * index + 1);
    }
  }
}
void build(int index, int sL, int sR) {
  if (sL == sR) {
    int val = s[sL];
    segTree[index].size = 1;
    segTree[index].in[val][val] = 1;
    segTree[index].pref[val][val] = 1;
    segTree[index].suff[val][val] = 1;
  } else {
    int mid = (sL + sR) / 2;
    build(2 * index, sL, mid);
    build(2 * index + 1, mid + 1, sR);
    segTree[index] = join(segTree[2 * index], segTree[2 * index + 1]);
  }
}
void print(int index, int sL, int sR) {
  propagate(index);
  if (sL == sR) {
    for (int val : {0, 1}) {
      if (segTree[index].in[val][val] == 1) {
        printf("%d", val);
      }
      if (segTree[index].pref[val][val] == 1) {
        printf("%d", val);
      }
      if (segTree[index].suff[val][val] == 1) {
        printf("%d", val);
      }
    }
  } else {
    int mid = (sL + sR) / 2;
    print(2 * index, sL, mid);
    print(2 * index + 1, mid + 1, sR);
  }
}
SegTree query(int index, int sL, int sR, int qL, int qR) {
  SegTree answer;
  if (sL == qL && sR == qR) {
    invert(index);
    propagate(index);
    answer = segTree[index];
  } else {
    propagate(index);
    int mid = (sL + sR) / 2;
    if (qR <= mid) {
      answer = query(2 * index, sL, mid, qL, qR);
    } else if (mid + 1 <= qL) {
      answer = query(2 * index + 1, mid + 1, sR, qL, qR);
    } else {
      answer = join(query(2 * index, sL, mid, qL, mid),
                    query(2 * index + 1, mid + 1, sR, mid + 1, qR));
    }
    segTree[index] = join(segTree[2 * index], segTree[2 * index + 1]);
  }
  return answer;
}
int main() {
  int n, q;
  scanf("%d%d", &n, &q);
  scanf("%s", s);
  for (int i = 0; s[i] != '\0'; i++) {
    if (s[i] == '>') {
      s[i] = 0;
    } else if (s[i] == '<') {
      s[i] = 1;
    }
  }
  build(1, 0, n - 1);
  for (int i = 0; i < q; i++) {
    int l, r;
    scanf("%d%d", &l, &r);
    l--;
    r--;
    SegTree q = query(1, 0, n - 1, l, r);
    int answer = std::max(std::max(q.in[0][0], q.in[0][1]), q.in[1][1]);
    printf("%d\n", answer);
  }
  return 0;
}
