#include <bits/stdc++.h>
using namespace std;
using namespace std;
const int maxn = 500000 + 10;
const int maxm = 2000 + 10;
struct node {
  int lr, ll, rr, rl, maxv, same;
  void clear() { lr = ll = rr = rl = maxv = same = 0; }
  void print() {
    fprintf(
        stderr,
        "left >: %d , left <: %d , right >: %d , right <: %d , Maxv: %d  %s\n",
        lr, ll, rr, rl, maxv, same ? "same" : "not same");
  }
};
char s[maxn];
node merge(const node& a, const node& b) {
  node c;
  if (a.maxv == 0 || b.maxv == 0) {
    c = a.maxv == 0 ? b : a;
    return c;
  }
  c.maxv = max(a.maxv, b.maxv);
  c.lr = a.lr, c.ll = a.ll;
  c.rl = b.rl, c.rr = b.rr;
  c.same = 1;
  if (a.rl == 0) {
    if (b.lr == 0) {
      c.maxv = max(c.maxv, b.ll + a.rr);
      if (a.same) {
        c.ll = b.ll;
      }
      if (b.same) {
        c.rr = a.rr;
      }
      c.same = b.same & a.same;
    } else {
      int tmp = a.rr + b.lr + b.ll;
      if (a.same) {
        c.lr += b.lr;
        c.ll += b.ll;
      }
      if (b.same) {
        c.rr += a.rr;
      }
      c.maxv = max(c.maxv, tmp);
      if (!a.same || !b.same) c.same = 0;
    }
  } else {
    if (b.lr == 0) {
      assert(b.ll != 0);
      c.maxv = max(c.maxv, a.rl + a.rr + b.ll);
      if (b.same) {
        c.rl += a.rl;
        c.rr += a.rr;
      }
      if (a.same) {
        c.ll += b.ll;
        c.lr += b.lr;
      }
      if (!a.same || !b.same) c.same = 0;
    } else {
      c.same = 0;
    }
  }
  if (c.same) {
    assert(c.lr == c.rr);
    assert(c.ll == c.rl);
  }
  return c;
}
struct segtree {
  node a[maxn << 2];
  node inv[maxn << 2];
  int flip[maxn << 2];
  int n, ql, qr;
  node ans;
  void init(int N) {
    n = N;
    build(1, n, 1);
  }
  void maintain(int l, int r, int o) {
    if (l != r) {
      a[o] = merge(a[o << 1], a[o << 1 | 1]);
      inv[o] = merge(inv[o << 1], inv[o << 1 | 1]);
    }
  }
  void build(int l, int r, int o) {
    flip[o] = 0;
    if (l == r) {
      node& x = a[o];
      node& y = inv[o];
      if (s[l] == '>') {
        x.same = 1;
        x.lr = 1;
        x.ll = 0;
        x.rr = 1;
        x.rl = 0;
        x.maxv = 1;
        y.same = 1;
        y.lr = 0;
        y.ll = 1;
        y.rr = 0;
        y.rl = 1;
        y.maxv = 1;
      } else {
        x.same = 1;
        x.lr = 0;
        x.ll = 1;
        x.rr = 0;
        x.rl = 1;
        x.maxv = 1;
        y.same = 1;
        y.lr = 1;
        y.ll = 0;
        y.rr = 1;
        y.rl = 0;
        y.maxv = 1;
      }
      return;
    }
    int mid = l + r >> 1;
    build(l, mid, o << 1), build(mid + 1, r, o << 1 | 1);
    maintain(l, r, o);
  }
  void pushdown(int l, int r, int o) {
    if (flip[o]) {
      flip[o << 1] ^= 1;
      flip[o << 1 | 1] ^= 1;
      swap(inv[o << 1], a[o << 1]);
      swap(inv[o << 1 | 1], a[o << 1 | 1]);
    }
    flip[o] = 0;
  }
  void update(int l, int r, int o) {
    if (ql <= l && qr >= r) {
      flip[o] ^= 1;
      swap(inv[o], a[o]);
      return;
    } else {
      int mid = l + r >> 1;
      pushdown(l, r, o);
      if (ql <= mid) update(l, mid, o << 1);
      if (qr > mid) update(mid + 1, r, o << 1 | 1);
      maintain(l, r, o);
    }
  }
  void query(int l, int r, int o) {
    if (ql <= l && qr >= r) {
      ans = merge(ans, a[o]);
    } else {
      int mid = l + r >> 1;
      pushdown(l, r, o);
      if (ql <= mid) query(l, mid, o << 1);
      if (qr > mid) query(mid + 1, r, o << 1 | 1);
      maintain(l, r, o);
    }
  }
  node Query(int l, int r) {
    ans.clear();
    ql = l, qr = r;
    update(1, n, 1);
    query(1, n, 1);
    return ans;
  }
};
segtree tree;
int n, q;
void test() {
  node a, b, c;
  a.maxv = 1;
  a.ll = a.rl = 0;
  a.rr = a.lr = 1;
  a.same = 1;
  b.maxv = 1;
  b.ll = b.rl = 1;
  b.rr = b.lr = 0;
  b.same = 1;
  c = merge(a, b);
  c.print();
  c = merge(c, b);
  c.print();
}
int main(void) {
  scanf("%d%d", &n, &q);
  scanf("%s", s + 1);
  tree.init(n);
  for (; q--;) {
    int l, r;
    scanf("%d%d", &l, &r);
    auto v = tree.Query(l, r);
    printf("%d\n", v.maxv);
  }
  return 0;
}
