// start of CP 3.0
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>

//____By:sirjan13____

#define int long long
#define ld long double
#define mod 1000000007
#define mod1 mod
#define mod2 100000009
#define show(a) for(int i=0;i<a.size();i++) cout<<a[i & 1]<<" ";
#define fi first
#define se second
#define vi vector<int>
#define vs vector<string>
#define vll vector<ll>
#define pb push_back
#define pi pair<int,int>
#define si set<int>
#define sll set<ll>
#define pll pair<ll, ll>
#define sci(x) scanf("%d",&x)
#define scs(x)  scanf("%s", x)
#define scll(x) scanf("%I64d",&x)
#define all(v) v.begin(),v.end()
#define sot(v) sort(v.begin(), v.end())
#define maxheap priority_queue<int>
#define minheap priority_queue<int,vector<int>,greater<int>>
#define mp make_pair
#define fast_io() cin.sync_with_stdio(false);cout.sync_with_stdio(false);
#define PI 3.1415926535
#define long_zero 0ll
#define long_one 1ll

inline int sbt(int x){return __builtin_popcount(x);}

using namespace std;
// using namespace __gnu_pbds;

#define TRACE
#ifdef TRACE
#define deb(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cout << name << " : " << arg1 << std::endl;
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
#else
#define deb(...)
#endif
#define N 500013
bool ok;

// typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ost;

inline int mul(int a, int b, int m = mod) { return (a * b) % m; }
inline int add(int a, int b, int m = mod) { return (a + b) % m; }
inline int sub(int a, int b, int m = mod) { return (a - b + m) % m; }

int dx[][2] = {{-1, 0}, {0, -1}, {1, 0}, {0, 1}};

int fastpow(int a, int b) {
    int res = 1;
    while(b > 0) {
        if(b & 1) res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}

int modinv(int a) {
    return fastpow(a, mod - 2);
}

int n, k, a[N];
string s;

// Segment Tree Template © :P

#define MAXN N

struct st {
    int p0;
    int p1;
    int s0;
    int s1;
    int p01;
    int s01;
    int p10;
    int s10;
    int max01;
    int max10;
    int len;

    st() {
        p0 = p1 = s0 = max01 = max10 = s1 = p10 = p01 = s01 = s10 = len = 1;
    }
    st(int i) {
        p0 = p1 = s0 = max01 = max10 = s1 = p10 = p01 = s01 = s10 = len = i;
    }
};

st tree[MAXN << 2];
bool lazy[MAXN << 2];

// Problem Specific
inline st merge(st lval, st rval) {
    st node(0);

    node.len = lval.len + rval.len;

    node.p0 = lval.p0;
    if(lval.p0 == lval.len) node.p0 += rval.p0;

    node.p1 = lval.p1;
    if(lval.p1 == lval.len) node.p1 += rval.p1;

    node.s0 = rval.s0;
    if(rval.s0 == rval.len) node.s0 += lval.s0;

    node.s1 = rval.s1;
    if(rval.s1 == rval.len) node.s1 += lval.s1;

    node.p01 = lval.p01;
    if(lval.p01 == lval.len) node.p01 += rval.p1;
    else if(lval.p0 == lval.len) node.p01 += rval.p01;

    node.p10 = lval.p10;
    if(lval.p10 == lval.len) node.p10 += rval.p0;
    else if(lval.p1 == lval.len) node.p10 += rval.p10;

    node.s01 = rval.s01;
    if(rval.s01 == rval.len) node.s01 += lval.s0;
    else if(rval.s1 == rval.len) node.s01 += lval.s01;

    node.s10 = rval.s10;
    if(rval.s10 == rval.len) node.s10 += lval.s1;
    else if(rval.s0 == rval.len) node.s10 += lval.s10;

    node.max01 = max(lval.max01, rval.max01);
    node.max01 = max(node.max01, max(lval.s0 + rval.p01, lval.s01 + rval.p1));
    node.max10 = max(lval.max10, rval.max10);
    node.max10 = max(node.max10, max(lval.s1 + rval.p10, lval.s10 + rval.p0));
    return node;
}

// Problem Specific
inline st get_val(int i) {
    st node;
    if(s[i - 1] == '<') {
        node.p0 = 0;
        node.s0 = 0;
    }
    else {
        node.s1 = 0;
        node.p1 = 0;
    }
    return node;
}

inline void build(int l, int r, int node = 1){
    if(l == r){
        // Problem Specific Node INIT
        tree[node] = get_val(l);
        return;
    }
    int mid = (l + r) >> 1, lc = 2 * node, rc = lc + 1;
    build(l , mid, lc);
    build(mid + 1, r, rc);
    tree[node] = merge(tree[lc], tree[rc]);
}

void f(st &node) {
    swap(node.p0,node.p1);
    swap(node.s0, node.s1);
    swap(node.p01, node.p10);
    swap(node.s01, node.s10);
    swap(node.max10, node.max01);
}

inline void push_down(int l, int r, int node){
    if(lazy[node] == 0) return;
    f(tree[node]);
    if(l != r) {
        lazy[2 * node] ^= lazy[node];
        lazy[(2 * node) + 1] ^= lazy[node];
    }
    lazy[node] = 0;
}

inline void update(int l, int r, int qs, int qe, int val, int node = 1){
    push_down(l, r, node);
    if(l > qe or r < qs) return;
    if(l >= qs and r <= qe){
        lazy[node] = val;
        push_down(l, r, node);
        return;
    }
    int mid = (l + r) >> 1, lc = 2 * node, rc = lc + 1;
    update(l , mid , qs , qe , val, lc);
    update(mid + 1 , r , qs , qe, val, rc);
    tree[node] = merge(tree[lc], tree[rc]);
}

inline st query(int l, int r, int qs, int qe, int node = 1){
    if(l > qe or r < qs) return st(0);
    push_down(l, r, node);
    if(l >= qs and r <= qe) return tree[node];
    int mid = l + r >> 1, lc = 2 * node , rc = lc + 1;
    return merge(query(l, mid, qs, qe, lc), query(mid + 1, r, qs, qe, rc));
}

// Problem

int32_t main() {
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    fast_io()
    int q;
    cin >> n >> q;
    cin >> s;
    build(1, n);
    while(q--) {
        int l, r;
        cin >> l >> r;
        update(1, n, l, r, 1);
        st res = query(1, n, l, r);
        cout << max({res.max01, res.p1, res.s0}) << endl;
        // cout << query(1, n, l, r).max01 << endl;
    }

    return 0;
}


// start of CP 3.0
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>

//____By:sirjan13____

#define int long long
#define ld long double
#define mod 1000000007
#define mod1 mod
#define mod2 100000009
#define show(a) for(int i=0;i<a.size();i++) cout<<a[i & 1]<<" ";
#define fi first
#define se second
#define vi vector<int>
#define vs vector<string>
#define vll vector<ll>
#define pb push_back
#define pi pair<int,int>
#define si set<int>
#define sll set<ll>
#define pll pair<ll, ll>
#define sci(x) scanf("%d",&x)
#define scs(x)  scanf("%s", x)
#define scll(x) scanf("%I64d",&x)
#define all(v) v.begin(),v.end()
#define sot(v) sort(v.begin(), v.end())
#define maxheap priority_queue<int>
#define minheap priority_queue<int,vector<int>,greater<int>>
#define mp make_pair
#define fast_io() cin.sync_with_stdio(false);cout.sync_with_stdio(false);
#define PI 3.1415926535
#define long_zero 0ll
#define long_one 1ll

inline int sbt(int x){return __builtin_popcount(x);}

using namespace std;
// using namespace __gnu_pbds;

#define TRACE
#ifdef TRACE
#define deb(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cout << name << " : " << arg1 << std::endl;
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
#else
#define deb(...)
#endif
#define N 500013
bool ok;

// typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ost;

inline int mul(int a, int b, int m = mod) { return (a * b) % m; }
inline int add(int a, int b, int m = mod) { return (a + b) % m; }
inline int sub(int a, int b, int m = mod) { return (a - b + m) % m; }

int dx[][2] = {{-1, 0}, {0, -1}, {1, 0}, {0, 1}};

int fastpow(int a, int b) {
    int res = 1;
    while(b > 0) {
        if(b & 1) res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}

int modinv(int a) {
    return fastpow(a, mod - 2);
}

int n, k, a[N];
string s;

// Segment Tree Template © :P

#define MAXN N

struct st {
    int p0;
    int p1;
    int s0;
    int s1;
    int p01;
    int s01;
    int p10;
    int s10;
    int max01;
    int max10;
    int len;

    st() {
        p0 = p1 = s0 = max01 = max10 = s1 = p10 = p01 = s01 = s10 = len = 1;
    }
    st(int i) {
        p0 = p1 = s0 = max01 = max10 = s1 = p10 = p01 = s01 = s10 = len = i;
    }
};

st tree[MAXN << 2];
bool lazy[MAXN << 2];

// Problem Specific
inline st merge(st lval, st rval) {
    st node(0);

    node.len = lval.len + rval.len;

    node.p0 = lval.p0;
    if(lval.p0 == lval.len) node.p0 += rval.p0;

    node.p1 = lval.p1;
    if(lval.p1 == lval.len) node.p1 += rval.p1;

    node.s0 = rval.s0;
    if(rval.s0 == rval.len) node.s0 += lval.s0;

    node.s1 = rval.s1;
    if(rval.s1 == rval.len) node.s1 += lval.s1;

    node.p01 = lval.p01;
    if(lval.p01 == lval.len) node.p01 += rval.p1;
    else if(lval.p0 == lval.len) node.p01 += rval.p01;

    node.p10 = lval.p10;
    if(lval.p10 == lval.len) node.p10 += rval.p0;
    else if(lval.p1 == lval.len) node.p10 += rval.p10;

    node.s01 = rval.s01;
    if(rval.s01 == rval.len) node.s01 += lval.s0;
    else if(rval.s1 == rval.len) node.s01 += lval.s01;

    node.s10 = rval.s10;
    if(rval.s10 == rval.len) node.s10 += lval.s1;
    else if(rval.s0 == rval.len) node.s10 += lval.s10;

    node.max01 = max(lval.max01, rval.max01);
    node.max01 = max(node.max01, max(lval.s0 + rval.p01, lval.s01 + rval.p1));
    node.max10 = max(lval.max10, rval.max10);
    node.max10 = max(node.max10, max(lval.s1 + rval.p10, lval.s10 + rval.p0));
    return node;
}

// Problem Specific
inline st get_val(int i) {
    st node;
    if(s[i - 1] == '<') {
        node.p0 = 0;
        node.s0 = 0;
    }
    else {
        node.s1 = 0;
        node.p1 = 0;
    }
    return node;
}

inline void build(int l, int r, int node = 1){
    if(l == r){
        // Problem Specific Node INIT
        tree[node] = get_val(l);
        return;
    }
    int mid = (l + r) >> 1, lc = 2 * node, rc = lc + 1;
    build(l , mid, lc);
    build(mid + 1, r, rc);
    tree[node] = merge(tree[lc], tree[rc]);
}

void f(st &node) {
    swap(node.p0, node.p1);
    swap(node.s0, node.s1);
    swap(node.p01, node.p10);
    swap(node.s01, node.s10);
    swap(node.max10, node.max01);
}

inline void push_down(int l, int r, int node){
    if(lazy[node] == 0) return;
    f(tree[node]);
    if(l != r) {
        lazy[2 * node] ^= lazy[node];
        lazy[(2 * node) + 1] ^= lazy[node];
    }
    lazy[node] = 0;
}

inline void update(int l, int r, int qs, int qe, int val, int node = 1){
    push_down(l, r, node);
    if(l > qe or r < qs) return;
    if(l >= qs and r <= qe){
        lazy[node] = val;
        push_down(l, r, node);
        return;
    }
    int mid = (l + r) >> 1, lc = 2 * node, rc = lc + 1;
    update(l , mid , qs , qe , val, lc);
    update(mid + 1 , r , qs , qe, val, rc);
    tree[node] = merge(tree[lc], tree[rc]);
}

inline st query(int l, int r, int qs, int qe, int node = 1){
    push_down(l, r, node);
    if(l > qe or r < qs) return st(0);
    if(l >= qs and r <= qe) return tree[node];
    int mid = l + r >> 1, lc = 2 * node , rc = lc + 1;
    return merge(query(l, mid, qs, qe, lc), query(mid + 1, r, qs, qe, rc));
}

// Problem

int32_t main() {
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    fast_io()
    int q;
    cin >> n >> q;
    cin >> s;
    build(1, n);
    while(q--) {
        int l, r;
        cin >> l >> r;
        update(1, n, l, r, 1);
        st res = query(1, n, l, r);
        cout << max({res.max01, res.p1, res.s0}) << endl;
        // cout << query(1, n, l, r).max01 << endl;
    }

    return 0;
}


// start of CP 3.0
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>

//____By:sirjan13____

#define int long long
#define ld long double
#define mod 1000000007
#define mod1 mod
#define mod2 100000009
#define show(a) for(int i=0;i<a.size();i++) cout<<a[i & 1]<<" ";
#define fi first
#define se second
#define vi vector<int>
#define vs vector<string>
#define vll vector<ll>
#define pb push_back
#define pi pair<int,int>
#define si set<int>
#define sll set<ll>
#define pll pair<ll, ll>
#define sci(x) scanf("%d",&x)
#define scs(x)  scanf("%s", x)
#define scll(x) scanf("%I64d",&x)
#define all(v) v.begin(),v.end()
#define sot(v) sort(v.begin(), v.end())
#define maxheap priority_queue<int>
#define minheap priority_queue<int,vector<int>,greater<int>>
#define mp make_pair
#define fast_io() cin.sync_with_stdio(false);cout.sync_with_stdio(false);
#define PI 3.1415926535
#define long_zero 0ll
#define long_one 1ll

inline int sbt(int x){return __builtin_popcount(x);}

using namespace std;
// using namespace __gnu_pbds;

#define TRACE
#ifdef TRACE
#define deb(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cout << name << " : " << arg1 << std::endl;
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
#else
#define deb(...)
#endif
#define N 500013
bool ok;

// typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ost;

inline int mul(int a, int b, int m = mod) { return (a * b) % m; }
inline int add(int a, int b, int m = mod) { return (a + b) % m; }
inline int sub(int a, int b, int m = mod) { return (a - b + m) % m; }

int dx[][2] = {{-1, 0}, {0, -1}, {1, 0}, {0, 1}};

int fastpow(int a, int b) {
    int res = 1;
    while(b > 0) {
        if(b & 1) res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}

int modinv(int a) {
    return fastpow(a, mod - 2);
}

int n, k, a[N];
string s;

// Segment Tree Template © :P

#define MAXN N

struct st {
    int p0;
    int p1;
    int s0;
    int s1;
    int p01;
    int s01;
    int p10;
    int s10;
    int max01;
    int max10;
    int len;

    st() {
        p0 = p1 = s0 = max01 = max10 = s1 = p10 = p01 = s01 = s10 = len = 1;
    }
    st(int i) {
        p0 = p1 = s0 = max01 = max10 = s1 = p10 = p01 = s01 = s10 = len = i;
    }
};

st tree[MAXN << 2];
bool lazy[MAXN << 2];

// Problem Specific
inline st merge(st lval, st rval) {
    st node(0);

    node.len = lval.len + rval.len;

    node.p0 = lval.p0;
    if(lval.p0 == lval.len) node.p0 += rval.p0;

    node.p1 = lval.p1;
    if(lval.p1 == lval.len) node.p1 += rval.p1;

    node.s0 = rval.s0;
    if(rval.s0 == rval.len) node.s0 += lval.s0;

    node.s1 = rval.s1;
    if(rval.s1 == rval.len) node.s1 += lval.s1;

    node.p01 = lval.p01;
    if(lval.p0 == lval.len) node.p01 += rval.p01;
    if(lval.p01 == lval.len) node.p01 += rval.p1;

    node.p10 = lval.p10;
    if(lval.p1 == lval.len) node.p10 += rval.p10;
    else if(lval.p10 == lval.len) node.p10 += rval.p0;

    node.s01 = rval.s01;
    if(rval.s1 == rval.len) node.s01 += lval.s01;
    else if(rval.s01 == rval.len) node.s01 += lval.s0;

    node.s10 = rval.s10;
    if(rval.s10 == rval.len) node.s10 += lval.s1;
    else if(rval.s0 == rval.len) node.s10 += lval.s10;

    node.max01 = max(lval.max01, rval.max01);
    node.max01 = max(node.max01, max(lval.s0 + rval.p01, lval.s01 + rval.p1));
    node.max10 = max(lval.max10, rval.max10);
    node.max10 = max(node.max10, max(lval.s1 + rval.p10, lval.s10 + rval.p0));
    // deb(node.p0, node.p1, node.p01, node.p10);
    // deb(node.p01, node.p10, node.s01, node.s10);
    // deb(node.len);
    // deb(node.max01, node.max10);

    return node;
}

// Problem Specific
inline st get_val(int i) {
    st node;
    if(s[i - 1] == '<') {
        node.p0 = 0;
        node.s0 = 0;
    }
    else {
        node.s1 = 0;
        node.p1 = 0;
    }
    return node;
}

inline void build(int l, int r, int node = 1){
    if(l == r){
        // Problem Specific Node INIT
        tree[node] = get_val(l);
        return;
    }
    int mid = (l + r) >> 1, lc = 2 * node, rc = lc + 1;
    build(l , mid, lc);
    build(mid + 1, r, rc);
    tree[node] = merge(tree[lc], tree[rc]);
}

void f(st &node) {
    swap(node.p0, node.p1);
    swap(node.s0, node.s1);
    swap(node.p01, node.p10);
    swap(node.s01, node.s10);
    swap(node.max10, node.max01);
}

inline void push_down(int l, int r, int node){
    if(lazy[node] == 0) return;
    f(tree[node]);
    if(l != r) {
        lazy[2 * node] ^= lazy[node];
        lazy[(2 * node) + 1] ^= lazy[node];
    }
    lazy[node] = 0;
}

inline void update(int l, int r, int qs, int qe, int val, int node = 1){
    push_down(l, r, node);
    if(l > qe or r < qs) return;
    if(l >= qs and r <= qe){
        lazy[node] = val;
        push_down(l, r, node);
        return;
    }
    int mid = (l + r) >> 1, lc = 2 * node, rc = lc + 1;
    update(l , mid , qs , qe , val, lc);
    update(mid + 1 , r , qs , qe, val, rc);
    tree[node] = merge(tree[lc], tree[rc]);
}

inline st query(int l, int r, int qs, int qe, int node = 1){
    push_down(l, r, node);
    if(l > qe or r < qs) return st(0);
    if(l >= qs and r <= qe) return tree[node];
    int mid = l + r >> 1, lc = 2 * node , rc = lc + 1;
    return merge(query(l, mid, qs, qe, lc), query(mid + 1, r, qs, qe, rc));
}

// Problem

int32_t main() {
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    fast_io()
    int q;
    cin >> n >> q;
    cin >> s;
    build(1, n);
    while(q--) {
        int l, r;
        cin >> l >> r;
        update(1, n, l, r, 1);
        st res = query(1, n, l, r);
        cout << max({res.max01, res.p1, res.s0}) << endl;
        // cout << query(1, n, l, r).max01 << endl;
    }

    return 0;
}


// start of CP 3.0
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>

//____By:sirjan13____

#define int long long
#define ld long double
#define mod 1000000007
#define mod1 mod
#define mod2 100000009
#define show(a) for(int i=0;i<a.size();i++) cout<<a[i & 1]<<" ";
#define fi first
#define se second
#define vi vector<int>
#define vs vector<string>
#define vll vector<ll>
#define pb push_back
#define pi pair<int,int>
#define si set<int>
#define sll set<ll>
#define pll pair<ll, ll>
#define sci(x) scanf("%d",&x)
#define scs(x)  scanf("%s", x)
#define scll(x) scanf("%I64d",&x)
#define all(v) v.begin(),v.end()
#define sot(v) sort(v.begin(), v.end())
#define maxheap priority_queue<int>
#define minheap priority_queue<int,vector<int>,greater<int>>
#define mp make_pair
#define fast_io() cin.sync_with_stdio(false);cout.sync_with_stdio(false);
#define PI 3.1415926535
#define long_zero 0ll
#define long_one 1ll

inline int sbt(int x){return __builtin_popcount(x);}

using namespace std;
// using namespace __gnu_pbds;

#define TRACE
#ifdef TRACE
#define deb(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cout << name << " : " << arg1 << std::endl;
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
#else
#define deb(...)
#endif
#define N 500013
bool ok;

// typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ost;

inline int mul(int a, int b, int m = mod) { return (a * b) % m; }
inline int add(int a, int b, int m = mod) { return (a + b) % m; }
inline int sub(int a, int b, int m = mod) { return (a - b + m) % m; }

int dx[][2] = {{-1, 0}, {0, -1}, {1, 0}, {0, 1}};

int fastpow(int a, int b) {
    int res = 1;
    while(b > 0) {
        if(b & 1) res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}

int modinv(int a) {
    return fastpow(a, mod - 2);
}

int n, k, a[N];
string s;

// Segment Tree Template © :P

#define MAXN N

struct st {
    int p0;
    int p1;
    int s0;
    int s1;
    int p01;
    int s01;
    int p10;
    int s10;
    int max01;
    int max10;
    int len;

    st() {
        p0 = p1 = s0 = max01 = max10 = s1 = p10 = p01 = s01 = s10 = len = 1;
    }
    st(int i) {
        p0 = p1 = s0 = max01 = max10 = s1 = p10 = p01 = s01 = s10 = len = i;
    }
};

st tree[MAXN << 2];
bool lazy[MAXN << 2];

// Problem Specific
inline st merge(st lval, st rval) {
    st node(0);

    node.len = lval.len + rval.len;

    // res.zero_ones=max({x.zero_ones,y.zero_ones,x.suf_zeros+y.pre_zero_ones,x.suf_zero_ones+y.pre_ones});
    // res.one_zeros=max({x.one_zeros,y.one_zeros,x.suf_ones+y.pre_one_zeros,x.suf_one_zeros+y.pre_zeros});
    node.p0 = lval.p0;
    if(lval.p0 == lval.len) node.p0 += rval.p0;

    node.p1 = lval.p1;
    if(lval.p1 == lval.len) node.p1 += rval.p1;

    node.s0 = rval.s0;
    if(rval.s0 == rval.len) node.s0 += lval.s0;

    node.s1 = rval.s1;
    if(rval.s1 == rval.len) node.s1 += lval.s1;

    node.p01 = lval.p01;
    if(lval.p01 == lval.len) node.p01 += rval.p1;
    else if(lval.p0 == lval.len) node.p01 += rval.p01;

    node.p10 = lval.p10;
    if(lval.p10 == lval.len) node.p10 += rval.p0;
    else if(lval.p1 == lval.len) node.p10 += rval.p10;

    node.s01 = rval.s01;
    if(rval.s01 == rval.len) node.s01 += lval.s0;
    else if(rval.s1 == rval.len) node.s01 += lval.s01;

    node.s10 = rval.s10;
    if(rval.s10 == rval.len) node.s10 += lval.s1;
    else if(rval.s0 == rval.len) node.s10 += lval.s10;

    node.max01 = max(lval.max01, rval.max01);
    node.max01 = max(node.max01, max({lval.s0 + rval.p01, lval.s01 + rval.p1, lval.p0 + rval.s1}));
    node.max10 = max(lval.max10, rval.max10);
    node.max10 = max(node.max10, max({lval.s1 + rval.p10, lval.s10 + rval.p0, lval.p1 + rval.s0}));
    return node;
}

// Problem Specific
inline st get_val(int i) {
    st node;
    if(s[i - 1] == '<') {
        node.p0 = 0;
        node.s0 = 0;
    }
    else {
        node.s1 = 0;
        node.p1 = 0;
    }
    return node;
}

inline void build(int l, int r, int node = 1){
    if(l == r){
        // Problem Specific Node INIT
        tree[node] = get_val(l);
        return;
    }
    int mid = (l + r) >> 1, lc = 2 * node, rc = lc + 1;
    build(l , mid, lc);
    build(mid + 1, r, rc);
    tree[node] = merge(tree[lc], tree[rc]);
}

void f(st &node) {
    swap(node.p0,node.p1);
    swap(node.s0, node.s1);
    swap(node.p01, node.p10);
    swap(node.s01, node.s10);
    swap(node.max10, node.max01);
}

inline void push_down(int l, int r, int node){
    if(lazy[node] == 0) return;
    f(tree[node]);
    if(l != r) {
        lazy[2 * node] ^= lazy[node];
        lazy[(2 * node) + 1] ^= lazy[node];
    }
    lazy[node] = 0;
}

inline void update(int l, int r, int qs, int qe, int val, int node = 1){
    push_down(l, r, node);
    if(l > qe or r < qs) return;
    if(l >= qs and r <= qe){
        lazy[node] = val;
        push_down(l, r, node);
        return;
    }
    int mid = (l + r) >> 1, lc = 2 * node, rc = lc + 1;
    update(l , mid , qs , qe , val, lc);
    update(mid + 1 , r , qs , qe, val, rc);
    tree[node] = merge(tree[lc], tree[rc]);
}

inline st query(int l, int r, int qs, int qe, int node = 1){
    if(l > qe or r < qs) return st(0);
    push_down(l, r, node);
    if(l >= qs and r <= qe) return tree[node];
    int mid = l + r >> 1, lc = 2 * node , rc = lc + 1;
    return merge(query(l, mid, qs, qe, lc), query(mid + 1, r, qs, qe, rc));
}

// Problem

int32_t main() {
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    fast_io()
    int q;
    cin >> n >> q;
    cin >> s;
    build(1, n);
    while(q--) {
        int l, r;
        cin >> l >> r;
        update(1, n, l, r, 1);
        st res = query(1, n, l, r);
        cout << max({res.max01, res.p1, res.s0}) << endl;
        // cout << query(1, n, l, r).max01 << endl;
    }

    return 0;
}


#include <bits/stdc++.h>
#define fst first
#define snd second
#define fore(i,a,b) for(int i=a,ThxDem=b;i<ThxDem;++i)
#define pb push_back
#define ALL(s) s.begin(),s.end()
#define FIN ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define SZ(s) int(s.size())
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;

struct node{
	int ampre,dirpre;
	int amsuf,dirsuf;
	int mx,len;
	int bstpre, bstsuf;
	node(int ampre, int dirpre, int amsuf, int dirsuf, int mx, int len, int bstpre, int bstsuf):
		ampre(ampre),dirpre(dirpre),amsuf(amsuf),dirsuf(dirsuf),mx(mx),len(len),bstpre(bstpre),bstsuf(bstsuf){}
	node(){}
};

node NEUT=node(-1,-1,-1,-1,-1,-1,-1,-1);

node merge(node &a, node &b){
	if(min(a.len,b.len)<0) return a.len<0?b:a;
	//ampre
	node ans;
	if(a.ampre==a.len&&a.dirpre==b.dirpre) ans.ampre=a.len+b.ampre;
	else ans.ampre=a.ampre;
	//amsuf
	if(b.amsuf==b.len&&b.dirsuf==a.dirsuf) ans.amsuf=b.len+a.amsuf;
	else ans.amsuf=b.amsuf;
	//dirpre
	ans.dirpre=a.dirpre;
	//dirsuf
	ans.dirsuf=b.dirsuf;
	//len
	ans.len=a.len+b.len;
	//bstsuf
	ans.bstsuf=b.bstsuf;
	if(b.amsuf==b.len){
		//><
		if(b.dirpre==0) ans.bstsuf=b.len+a.bstsuf;
		else ans.bstsuf=b.len+a.amsuf;
	}
	//bstpre
	ans.bstpre=a.bstpre;
	if(a.ampre==a.len){
		if(a.dirsuf==1) ans.bstpre=a.len+b.bstpre;
		else ans.bstpre=a.len+b.ampre;
	}
	//mx
	ans.mx=max(a.mx,b.mx);
	ans.mx=max(ans.mx,ans.bstsuf);
	ans.mx=max(ans.mx,ans.bstpre);
	if(a.dirsuf==b.dirpre){
		//>>
		if(a.dirsuf==1) ans.mx=max(ans.mx,a.amsuf+b.bstpre);
		//<<
		if(a.dirsuf==0) ans.mx=max(ans.mx,a.bstsuf+b.ampre);
	}
	else{
		//><
		if(a.dirsuf==1&&b.dirpre==0) ans.mx=max(ans.mx,a.amsuf+b.ampre);
	}
	return ans;
}

struct STree { // example: range sum with range addition
	vector<node> st; vector<char> lazy;int n;
	STree(int n): st(4*n+5,NEUT), lazy(4*n+5,0), n(n) {}
	void init(int k, int s, int e, vector<int> &a){
		lazy[k]=0;  // lazy neutral element
		if(s+1==e){st[k]=node(1,a[s],1,a[s],1,1,1,1);return;}
		int m=(s+e)/2;
		init(2*k,s,m,a);init(2*k+1,m,e,a);
		st[k]=merge(st[2*k],st[2*k+1]); // operation
	}
	void push(int k, int s, int e){
		if(!lazy[k])return; // if neutral, nothing to do
		st[k].dirpre^=1;
		st[k].dirsuf^=1;
		if(s+1<e){ // propagate to children
			lazy[2*k]^=lazy[k];
			lazy[2*k+1]^=lazy[k];
		}
		lazy[k]=0; // clear node lazy
	}
	void upd(int k, int s, int e, int a, int b, int v){
		push(k,s,e);
		if(s>=b||e<=a)return;
		if(s>=a&&e<=b){
			lazy[k]^=1; // accumulate lazy
			push(k,s,e);return;
		}
		int m=(s+e)/2;
		upd(2*k,s,m,a,b,v);upd(2*k+1,m,e,a,b,v);
		st[k]=merge(st[2*k],st[2*k+1]); // operation
	}
	node query(int k, int s, int e, int a, int b){
		if(s>=b||e<=a)return NEUT; // operation neutral
		push(k,s,e);
		if(s>=a&&e<=b)return st[k];
		int m=(s+e)/2;
		node l=query(2*k,s,m,a,b);
		node r=query(2*k+1,m,e,a,b);
		return merge(l,r);
	}
	void init(vector<int> &a){init(1,0,n,a);}
	void upd(int a, int b, int v){upd(1,0,n,a,b,v);}
	node query(int a, int b){return query(1,0,n,a,b);}
}; // usage: STree rmq(n);rmq.init(x);rmq.upd(s,e,v);rmq.query(s,e);

int main(){FIN;
	int n,q; cin>>n>>q;
	string s; cin>>s;
	vector<int> a(n);
	fore(i,0,n) a[i]=s[i]=='>';
	STree st(n);
	st.init(a);
	while(q--){
		int l,r; cin>>l>>r; l--; r--;
		st.upd(l,r+1,1);
		fore(i,0,n) st.query(i,i);
		node ans=st.query(l,r+1);
		cout<<ans.mx<<"\n";
	}
}


#include <bits/stdc++.h>
#define fst first
#define snd second
#define fore(i,a,b) for(int i=a,ThxDem=b;i<ThxDem;++i)
#define pb push_back
#define ALL(s) s.begin(),s.end()
#define FIN ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define SZ(s) int(s.size())
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;

struct node{
	int dirpre,dirsuf,mx,len,pre,suf,pre2,suf2,mx2;
};

node NEUT={-1,-1,-1,-1,-1,-1,-1,-1,-1};

node merge(node &a, node &b){
	if(min(a.len,b.len)<0) return a.len<0?b:a;
	node ans={a.dirpre,b.dirsuf,0,a.len+b.len,a.pre,b.suf,a.pre2,a.suf2,0};
	int can1=a.dirsuf||!b.dirpre, can2=!a.dirsuf||b.dirpre;

	if(b.suf==b.len&&can1) ans.suf+=a.suf;
	if(a.pre==a.len&&can1) ans.pre+=b.pre;
	ans.mx=max({a.mx,b.mx,ans.suf,ans.pre});
	if(can1) ans.mx=max(ans.mx,a.suf+b.pre);

	if(b.suf2==b.len&&can2) ans.suf2+=a.suf2;
	if(a.pre2==a.len&&can2) ans.pre2+=b.pre2;
	ans.mx2=max({a.mx2,b.mx2,ans.suf2,ans.pre2});
	if(can2) ans.mx2=max(ans.mx2,a.suf2+b.pre2);

	return ans;
}

struct STree { // example: range sum with range addition
	vector<node> st; vector<int> lazy;int n;
	STree(int n): st(4*n+5,NEUT), lazy(4*n+5,0), n(n) {}
	void init(int k, int s, int e, vector<int> &a){
		lazy[k]=0;  // lazy neutral element
		if(s+1==e){st[k]={a[s],a[s],1,1,1,1,1,1,1};return;}
		int m=(s+e)/2;
		init(2*k,s,m,a);init(2*k+1,m,e,a);
		st[k]=merge(st[2*k],st[2*k+1]); // operation
	}
	void push(int k, int s, int e){
		if(!lazy[k])return; // if neutral, nothing to do
		swap(st[k].mx,st[k].mx2);
		swap(st[k].pre,st[k].pre2);
		swap(st[k].suf,st[k].suf2);
		st[k].dirpre^=1;
		st[k].dirsuf^=1;
		if(s+1<e){ // propagate to children
			lazy[2*k]^=lazy[k];
			lazy[2*k+1]^=lazy[k];
		}
		lazy[k]=0; // clear node lazy
	}
	void upd(int k, int s, int e, int a, int b, int v){
		push(k,s,e);
		if(s>=b||e<=a)return;
		if(s>=a&&e<=b){
			lazy[k]^=1; // accumulate lazy
			push(k,s,e);return;
		}
		int m=(s+e)/2;
		upd(2*k,s,m,a,b,v);upd(2*k+1,m,e,a,b,v);
		st[k]=merge(st[2*k],st[2*k+1]); // operation
	}
	node query(int k, int s, int e, int a, int b){
		if(s>=b||e<=a)return NEUT; // operation neutral
		push(k,s,e);
		if(s>=a&&e<=b) return st[k];
		int m=(s+e)/2;
		node l=query(2*k,s,m,a,b);
		node r=query(2*k+1,m,e,a,b);
		return merge(l,r);
	}
	void init(vector<int> &a){init(1,0,n,a);}
	void upd(int a, int b, int v){upd(1,0,n,a,b,v);}
	node query(int a, int b){return query(1,0,n,a,b);}
}; // usage: STree rmq(n);rmq.init(x);rmq.upd(s,e,v);rmq.query(s,e);

int main(){FIN;
	int n,q; cin>>n>>q;
	string s; cin>>s;
	vector<int> a(n);
	fore(i,0,n) a[i]=s[i]=='>';
	STree st(n);
	st.init(a);
	while(q--){
		int l,r; cin>>l>>r; l--; r--;
		st.upd(l,r+1,1);
		cout<<st.query(l,r+1).mx<<"\n";
	}
}


#include <bits/stdc++.h>
#define fst first
#define snd second
#define fore(i,a,b) for(int i=a,ThxDem=b;i<ThxDem;++i)
#define pb push_back
#define ALL(s) s.begin(),s.end()
#define FIN ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define SZ(s) int(s.size())
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;

struct node{
	int dl,dr,mx,len,pre,suf,pre2,suf2,mx2;
};

node NEUT={-1,-1,-1,-1,-1,-1,-1,-1,-1};

node merge(node &a, node &b){
	if(min(a.len,b.len)<0) return a.len<0?b:a;
	node ans={a.dl,b.dr,0,a.len+b.len,a.pre,b.suf,a.pre2,b.suf2,0};
	int can1=a.dr||!b.dl;
	int can2=b.dl||!a.dr;

	if(b.suf==b.len&&can1) ans.suf+=a.suf;
	if(a.pre==a.len&&can1) ans.pre+=b.pre;
	ans.mx=max({a.mx,b.mx,ans.suf,ans.pre});
	if(can1) ans.mx=max(ans.mx,a.suf+b.pre);

	if(b.suf2==b.len&&can2) ans.suf2+=a.suf2;
	if(a.pre2==a.len&&can2) ans.pre2+=b.pre2;
	ans.mx2=max({a.mx2,b.mx2,ans.suf2,ans.pre2});
	if(can2) ans.mx2=max(ans.mx2,a.suf2+b.pre2);

	return ans;
}

struct STree{
	vector<node> st; vector<int> lazy;int n;
	STree(int n): st(4*n+5,NEUT), lazy(4*n+5,0), n(n) {}
	void init(int k, int s, int e, vector<int> &a){
		lazy[k]=0;
		if(s+1==e){st[k]={a[s],a[s],1,1,1,1,1,1,1};return;}
		int m=(s+e)/2;
		init(2*k,s,m,a);init(2*k+1,m,e,a);
		st[k]=merge(st[2*k],st[2*k+1]);
	}
	void push(int k, int s, int e){
		if(!lazy[k])return;
		swap(st[k].mx,st[k].mx2);
		swap(st[k].pre,st[k].pre2);
		swap(st[k].suf,st[k].suf2);
		st[k].dl^=1;
		st[k].dr^=1;
		if(s+1<e){
			lazy[2*k]^=lazy[k];
			lazy[2*k+1]^=lazy[k];
		}
		lazy[k]=0;
	}
	void upd(int k, int s, int e, int a, int b, int v){
		push(k,s,e);
		if(s>=b||e<=a)return;
		if(s>=a&&e<=b){
			lazy[k]^=1;
			push(k,s,e);return;
		}
		int m=(s+e)/2;
		upd(2*k,s,m,a,b,v);upd(2*k+1,m,e,a,b,v);
		st[k]=merge(st[2*k],st[2*k+1]);
	}
	node query(int k, int s, int e, int a, int b){
		if(s>=b||e<=a)return NEUT;
		push(k,s,e);
		if(s>=a&&e<=b) return st[k];
		int m=(s+e)/2;
		node l=query(2*k,s,m,a,b);
		node r=query(2*k+1,m,e,a,b);
		return merge(l,r);
	}
	void init(vector<int> &a){init(1,0,n,a);}
	void upd(int a, int b, int v){upd(1,0,n,a,b,v);}
	node query(int a, int b){return query(1,0,n,a,b);}
};

int main(){FIN;
	int n,q; cin>>n>>q;
	string s; cin>>s;
	vector<int> a(n);
	fore(i,0,n) a[i]=s[i]=='>';
	STree st(n);
	st.init(a);
	while(q--){
		int l,r; cin>>l>>r; l--; r--;
		st.upd(l,r+1,1);
		cout<<st.query(l,r+1).mx<<"\n";
	}
}


#include <bits/stdc++.h>
#define fst first
#define snd second
#define fore(i,a,b) for(int i=a,ThxDem=b;i<ThxDem;++i)
#define pb push_back
#define ALL(s) s.begin(),s.end()
#define FIN ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define SZ(s) int(s.size())
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;

struct node{
	int ampre,dirpre;
	int amsuf,dirsuf;
	int mx,len;
	int bstpre, bstsuf;
	node(int ampre, int dirpre, int amsuf, int dirsuf, int mx, int len, int bstpre, int bstsuf):
		ampre(ampre),dirpre(dirpre),amsuf(amsuf),dirsuf(dirsuf),mx(mx),len(len),bstpre(bstpre),bstsuf(bstsuf){}
	node(){}
};

node NEUT=node(-1,-1,-1,-1,-1,-1,-1,-1);

node merge(node a, node b){
	if(min(a.len,b.len)<0) return a.len<0?b:a;
	//ampre
	node ans;
	if(a.ampre==a.len&&a.dirpre==b.dirpre) ans.ampre=a.len+b.ampre;
	else ans.ampre=a.ampre;
	//amsuf
	if(b.amsuf==b.len&&b.dirsuf==a.dirsuf) ans.amsuf=b.len+a.amsuf;
	else ans.amsuf=b.amsuf;
	//dirpre
	ans.dirpre=a.dirpre;
	//dirsuf
	ans.dirsuf=b.dirsuf;
	//len
	ans.len=a.len+b.len;
	//bstsuf
	ans.bstsuf=b.bstsuf;
	if(b.amsuf==b.len){
		//><
		if(b.dirpre==0) ans.bstsuf=b.len+a.bstsuf;
		else ans.bstsuf=b.len+a.amsuf;
	}
	//bstpre
	ans.bstpre=a.bstpre;
	if(a.ampre==a.len){
		if(a.dirsuf==1) ans.bstpre=a.len+b.bstpre;
		else ans.bstpre=a.len+b.ampre;
	}
	//mx
	ans.mx=max(a.mx,b.mx);
	ans.mx=max(ans.mx,ans.bstsuf);
	ans.mx=max(ans.mx,ans.bstpre);
	if(a.dirsuf==b.dirpre){
		//>>
		if(a.dirsuf==1) ans.mx=max(ans.mx,a.amsuf+b.bstpre);
		//<<
		if(a.dirsuf==0) ans.mx=max(ans.mx,a.bstsuf+b.ampre);
	}
	else{
		//><
		if(a.dirsuf==1&&b.dirpre==0) ans.mx=max(ans.mx,a.amsuf+b.ampre);
	}
	return ans;
}

struct STree { // example: range sum with range addition
	vector<node> st; vector<int> lazy;int n;
	STree(int n): st(4*n+5,NEUT), lazy(4*n+5,0), n(n) {}
	void init(int k, int s, int e, vector<int> &a){
		lazy[k]=0;  // lazy neutral element
		if(s+1==e){st[k]=node(1,a[s],1,a[s],1,1,1,1);return;}
		int m=(s+e)/2;
		init(2*k,s,m,a);init(2*k+1,m,e,a);
		st[k]=merge(st[2*k],st[2*k+1]); // operation
	}
	void push(int k, int s, int e){
		if(!lazy[k])return; // if neutral, nothing to do
		st[k].dirpre^=1;
		st[k].dirsuf^=1;
		if(s+1<e){ // propagate to children
			lazy[2*k]^=lazy[k];
			lazy[2*k+1]^=lazy[k];
		}
		lazy[k]=0; // clear node lazy
	}
	void upd(int k, int s, int e, int a, int b, int v){
		push(k,s,e);
		if(s>=b||e<=a)return;
		if(s>=a&&e<=b){
			lazy[k]^=1; // accumulate lazy
			push(k,s,e);return;
		}
		int m=(s+e)/2;
		upd(2*k,s,m,a,b,v);upd(2*k+1,m,e,a,b,v);
		st[k]=merge(st[2*k],st[2*k+1]); // operation
	}
	node query(int k, int s, int e, int a, int b){
		if(s>=b||e<=a)return NEUT; // operation neutral
		push(k,s,e);
		if(s>=a&&e<=b)return st[k];
		int m=(s+e)/2;
		return merge(query(2*k,s,m,a,b),query(2*k+1,m,e,a,b)); // operation
	}
	void init(vector<int> &a){init(1,0,n,a);}
	void upd(int a, int b, int v){upd(1,0,n,a,b,v);}
	node query(int a, int b){return query(1,0,n,a,b);}
}; // usage: STree rmq(n);rmq.init(x);rmq.upd(s,e,v);rmq.query(s,e);

int main(){FIN;
	int n,q; cin>>n>>q;
	string s; cin>>s;
	vector<int> a(n);
	fore(i,0,n) a[i]=s[i]=='>';
	STree st(n);
	st.init(a);
	while(q--){
		int l,r; cin>>l>>r; l--; r--;
		st.upd(l,r+1,1);
		fore(i,0,n) st.query(i,i);
		node ans=st.query(l,r+1);
		cout<<ans.mx<<"\n";
	}
}


#include <bits/stdc++.h>
#define fst first
#define snd second
#define fore(i,a,b) for(int i=a,ThxDem=b;i<ThxDem;++i)
#define pb push_back
#define ALL(s) s.begin(),s.end()
#define FIN ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define SZ(s) int(s.size())
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;

struct node{
	bool dirpre,dirsuf;
	int len;
	int mx,pre,suf;
	int mx2,pre2,suf2;
	node(bool dirpre, bool dirsuf, int mx, int len, int pre, int suf, int pre2, int suf2, int mx2):
		dirpre(dirpre),dirsuf(dirsuf),mx(mx),len(len),pre(pre),suf(suf),pre2(pre2),suf2(suf2),mx2(mx2){}
	node(){}
};

node NEUT=node(-1,-1,-1,-1,-1,-1,-1,-1,-1);

node merge(node &a, node &b){
	if(min(a.len,b.len)<0) return a.len<0?b:a;
	node ans;
	//dirpre
	ans.dirpre=a.dirpre;
	//dirsuf
	ans.dirsuf=b.dirsuf;
	//len
	ans.len=a.len+b.len;

	//suf
	ans.suf=b.suf;
	if(b.suf==b.len&&(a.dirsuf!=0||b.dirpre!=1)) ans.suf+=a.suf;
	//pre
	ans.pre=a.pre;
	if(a.pre==a.len&&(a.dirsuf!=0||b.dirpre!=1)) ans.pre+=b.pre;
	//mx
	ans.mx=max({a.mx,b.mx,ans.suf,ans.pre});
	if(a.dirsuf!=0||b.dirpre!=1) ans.mx=max(ans.mx,a.suf+b.pre);

	//suf2
	ans.suf2=b.suf2;
	if(b.suf2==b.len&&(a.dirsuf!=1||b.dirpre!=0)) ans.suf2+=a.suf2;
	//pre2
	ans.pre2=a.pre2;
	if(a.pre2==a.len&&(a.dirsuf!=1||b.dirpre!=0)) ans.pre2+=b.pre2;
	//mx2
	ans.mx2=max({a.mx2,b.mx2,ans.suf2,ans.pre2});
	if(a.dirsuf!=1||b.dirpre!=0) ans.mx2=max(ans.mx2,a.suf2+b.pre2);

	return ans;
}

struct STree { // example: range sum with range addition
	vector<node> st; vector<int> lazy;int n;
	STree(int n): st(4*n+5,NEUT), lazy(4*n+5,0), n(n) {}
	void init(int k, int s, int e, vector<int> &a){
		lazy[k]=0;  // lazy neutral element
		if(s+1==e){st[k]=node(a[s],a[s],1,1,1,1,1,1,1);return;}
		int m=(s+e)/2;
		init(2*k,s,m,a);init(2*k+1,m,e,a);
		st[k]=merge(st[2*k],st[2*k+1]); // operation
	}
	void push(int k, int s, int e){
		if(!lazy[k])return; // if neutral, nothing to do
		swap(st[k].mx,st[k].mx2);
		swap(st[k].pre,st[k].pre2);
		swap(st[k].suf,st[k].suf2);
		st[k].dirpre^=1;
		st[k].dirsuf^=1;
		if(s+1<e){ // propagate to children
			lazy[2*k]^=lazy[k];
			lazy[2*k+1]^=lazy[k];
		}
		lazy[k]=0; // clear node lazy
	}
	void upd(int k, int s, int e, int a, int b, int v){
		push(k,s,e);
		if(s>=b||e<=a)return;
		if(s>=a&&e<=b){
			lazy[k]^=1; // accumulate lazy
			push(k,s,e);return;
		}
		int m=(s+e)/2;
		upd(2*k,s,m,a,b,v);upd(2*k+1,m,e,a,b,v);
		st[k]=merge(st[2*k],st[2*k+1]); // operation
	}
	node query(int k, int s, int e, int a, int b){
		if(s>=b||e<=a)return NEUT; // operation neutral
		push(k,s,e);
		if(s>=a&&e<=b) return st[k];
		int m=(s+e)/2;
		node l=query(2*k,s,m,a,b);
		node r=query(2*k+1,m,e,a,b);
		return merge(l,r);
	}
	void init(vector<int> &a){init(1,0,n,a);}
	void upd(int a, int b, int v){upd(1,0,n,a,b,v);}
	node query(int a, int b){return query(1,0,n,a,b);}
}; // usage: STree rmq(n);rmq.init(x);rmq.upd(s,e,v);rmq.query(s,e);

int main(){FIN;
	int n,q; cin>>n>>q;
	string s; cin>>s;
	vector<int> a(n);
	fore(i,0,n) a[i]=s[i]=='>';
	STree st(n);
	st.init(a);

	while(q--){
		int l,r; cin>>l>>r; l--; r--;
		st.upd(l,r+1,1);
		node ans=st.query(l,r+1);
		cout<<ans.mx<<"\n";
	}
}


#include <bits/stdc++.h>
using namespace std;
#define mid ((s + e) / 2)
#define makefast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define comp(x) (lower_bound(vec.begin(), vec.end(), x) - vec.begin())
#define lc (v * 2)
#define rc (v * 2 + 1)
long long M = 1e9 + 7;
//>>>>>>>>>>>>>>>>>>>>>>>

struct node {
	int sz;
	int knd[2];
	int len[2];
	int slen[2];
	int mx[2];
//	knd[0] = knd[1] = len[0] = len[1] = slen[0] = slen[1] = 0;
};
node operator +(const node& s, const node& t) {
	node res;
	res.sz = s.sz + t.sz;
	res.knd[0] = s.knd[0];
	res.knd[1] = t.knd[1];
	if (s.len[0] < s.sz || s.knd[0] != t.knd[0])
		res.len[0] = s.len[0];
	else
		res.len[0] = s.len[0] + t.len[0];
	if (t.len[1] < t.sz || s.knd[1] != t.knd[1])
		res.len[1] = t.len[1];
	else
		res.len[1] = s.len[1] + t.len[1];
	if (res.len[1] != res.sz) {
		if (s.len[0] == s.sz) {
			if (s.knd[0] == t.knd[0])
				res.slen[0] = t.slen[0];
			else
				res.slen[0] = t.len[0];
		}
		else {
			if (s.slen[0] + s.len[0] == s.sz && s.knd[0] != t.knd[0])
				res.slen[0] = s.slen[0] + t.len[0];
			else
				res.slen[0] = s.slen[0];
		}
		if (t.len[1] == t.sz) {
			if (s.knd[1] == t.knd[1])
				res.slen[1] = s.slen[1];
			else
				res.slen[1] = s.len[1];
		}
		else {
			if (t.slen[1] + t.len[1] == t.sz && t.knd[1] != s.knd[1])
				res.slen[1] = t.slen[1] + s.len[1];
			else
				res.slen[1] = t.slen[1];
		}
	}
	else
		res.slen[0] = res.slen[1] = 0;
	res.mx[0] = max(s.mx[0], t.mx[0]);
	res.mx[1] = max(s.mx[1], t.mx[1]);
	if (s.knd[1] == 1 && t.knd[0] == 0)
		res.mx[0] = max(res.mx[0], s.len[1] + t.len[0]);
	if (s.knd[1] == 0 && t.knd[0] == 1)
		res.mx[1] = max(res.mx[1], s.len[1] + t.len[0]);
	if (s.knd[1] == 1 && t.knd[0] == 1) {
		res.mx[0] = max(res.mx[0], s.len[1] + t.len[0] + t.slen[0]);
		res.mx[1] = max(res.mx[1], s.slen[1] + s.len[1] + t.len[0]);
	}
	if (s.knd[1] == 0 && t.knd[0] == 0) {
		res.mx[0] = max(res.mx[0], s.slen[1] + s.len[1] + t.len[0]);
		res.mx[1] = max(res.mx[1], s.len[1] + t.len[0] + t.slen[0]);
	}
	return res;
}
void operator ~(node& s) {
	s.knd[0] ^= 1;
	s.knd[1] ^= 1;
	swap(s.mx[0], s.mx[1]);
}
const int N = 5e5 + 7;

node seg[N * 4];
bool laz[N * 4];
int n, q;
string str;
void prep(int v = 1, int s = 1, int e = n + 1) {
	if (e - s == 1) {
		seg[v].len[0] = seg[v].len[1] = 1;
		if (str[s - 1] == '>')
			seg[v].knd[0] = seg[v].knd[1] = 1;
		seg[v].mx[0] = seg[v].mx[1] = seg[v].sz = 1;
		return;
	}
	prep(lc, s, mid);
	prep(rc, mid, e);
	seg[v] = seg[lc] + seg[rc];
//	cout << " prep : " << s << ' ' << e << " > " << seg[v].len[0] << ' ' << seg[v].len[1] << endl;
}
void spl(int v) {
	for (int u = lc; u <= rc; u++)
		if (laz[v]) {
			~seg[u];
			laz[u] ^= 1;
		}
	laz[v] = 0;
}

void rev(int l, int r, int v = 1, int s = 1, int e = n + 1) {
	if (r <= s || e <= l)
		return;
	if (l <= s && e <= r) {
		~seg[v];
		laz[v] ^= 1;
		return;
	}
	spl(v);
	rev(l, r, lc, s, mid);
	rev(l, r, rc, mid, e);
	seg[v] = seg[lc] + seg[rc];
}

node get(int l, int r, int v = 1, int s = 1, int e = n + 1) {
	if (r <= s || e <= l)
		return seg[0];
	if (l <= s && e <= r) {
		return seg[v];
	}
	spl(v);
	return get(l, r, lc, s, mid) + get(l, r, rc, mid, e);
}

int main() {
	makefast;
	cin >> n >> q;
	cin >> str;
	prep();
//	cout << seg[1].mx[0] << ' ' << seg[1].mx[1] << endl;
	while (q--) {
		int l, r;
		cin >> l >> r;
		rev(l, r + 1);
		node s = get(l, r + 1);
	/*	cout << " > " << s.mx[0] << " " << s.len[0] << ' ' << s.len[1] << ' ' << s.slen[0] << ' ' << s.slen[1] << ' ' << s.knd[0] << ' ' << s.knd[1] << ' ' << s.sz << " " << s.mx[1] << endl;*/
		cout << s.mx[0] << ' ';
	}
}


#include <bits/stdc++.h>
using namespace std;
#define mid ((s + e) / 2)
#define makefast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define comp(x) (lower_bound(vec.begin(), vec.end(), x) - vec.begin())
#define lc (v * 2)
#define rc (v * 2 + 1)
long long M = 1e9 + 7;
//>>>>>>>>>>>>>>>>>>>>>>>

struct node {
	int sz;
	int knd[2];
	int len[2];
	int slen[2];
	int mx[2];
//	knd[0] = knd[1] = len[0] = len[1] = slen[0] = slen[1] = 0;
};
node operator +(const node& s, const node& t) {
	node res;
	res.sz = s.sz + t.sz;
	res.knd[0] = s.knd[0];
	res.knd[1] = t.knd[1];
	if (s.len[0] < s.sz || s.knd[0] != t.knd[0])
		res.len[0] = s.len[0];
	else
		res.len[0] = s.len[0] + t.len[0];
	if (t.len[1] < t.sz || s.knd[1] != t.knd[1])
		res.len[1] = t.len[1];
	else
		res.len[1] = s.len[1] + t.len[1];
	if (res.len[1] != res.sz) {
		if (s.len[0] == s.sz) {
			if (s.knd[0] == t.knd[0])
				res.slen[0] = t.slen[0];
			else
				res.slen[0] = t.len[0];
		}
		else {
			if (s.slen[0] + s.len[0] == s.sz && s.knd[0] != t.knd[0])
				res.slen[0] = s.slen[0] + t.len[0];
			else
				res.slen[0] = s.slen[0];
		}
		if (t.len[1] == t.sz) {
			if (s.knd[1] == t.knd[1])
				res.slen[1] = s.slen[1];
			else
				res.slen[1] = s.len[1];
		}
		else {
			if (t.slen[1] + t.len[1] == t.sz && t.knd[1] != s.knd[1])
				res.slen[1] = t.slen[1] + s.len[1];
			else
				res.slen[1] = s.slen[1];
		}
	}
	else
		res.slen[0] = res.slen[1] = 0;
	res.mx[0] = max(s.mx[0], t.mx[0]);
	res.mx[1] = max(s.mx[1], t.mx[1]);
	if (s.knd[1] == 1 && t.knd[0] == 0)
		res.mx[0] = max(res.mx[0], s.len[1] + t.len[0]);
	if (s.knd[1] == 0 && t.knd[0] == 1)
		res.mx[1] = max(res.mx[1], s.len[1] + t.len[0]);
	if (s.knd[1] == 1 && t.knd[0] == 1) {
		res.mx[0] = max(res.mx[0], s.len[1] + t.len[0] + t.slen[0]);
		res.mx[1] = max(res.mx[1], s.slen[1] + s.len[1] + t.len[0]);
	}
	if (s.knd[1] == 0 && t.knd[0] == 0) {
		res.mx[0] = max(res.mx[0], s.slen[1] + s.len[1] + t.len[0]);
		res.mx[1] = max(res.mx[1], s.len[1] + t.len[0] + t.slen[0]);
	}
	return res;
}
void operator ~(node& s) {
	s.knd[0] ^= 1;
	s.knd[1] ^= 1;
	swap(s.mx[0], s.mx[1]);
}
const int N = 5e5 + 7;

node seg[N * 4];
bool laz[N * 4];
int n, q;
string str;
void prep(int v = 1, int s = 1, int e = n + 1) {
	if (e - s == 1) {
		seg[v].len[0] = seg[v].len[1] = 1;
		if (str[s - 1] == '>')
			seg[v].knd[0] = seg[v].knd[1] = 1;
		seg[v].mx[0] = seg[v].mx[1] = seg[v].sz = 1;
		return;
	}
	prep(lc, s, mid);
	prep(rc, mid, e);
	seg[v] = seg[lc] + seg[rc];
//	cout << " prep : " << s << ' ' << e << " > " << seg[v].len[0] << ' ' << seg[v].len[1] << endl;
}
void spl(int v) {
	for (int u = lc; u <= rc; u++)
		if (laz[v]) {
			~seg[u];
			laz[u] ^= 1;
		}
	laz[v] = 0;
}

void rev(int l, int r, int v = 1, int s = 1, int e = n + 1) {
	if (r <= s || e <= l)
		return;
	if (l <= s && e <= r) {
		~seg[v];
		laz[v] ^= 1;
		return;
	}
	spl(v);
	rev(l, r, lc, s, mid);
	rev(l, r, rc, mid, e);
	seg[v] = seg[lc] + seg[rc];
}

node get(int l, int r, int v = 1, int s = 1, int e = n + 1) {
	if (r <= s || e <= l)
		return seg[0];
	if (l <= s && e <= r) {
		return seg[v];
	}
	spl(v);
	return get(l, r, lc, s, mid) + get(l, r, rc, mid, e);
}

int main() {
	makefast;
	cin >> n >> q;
	cin >> str;
	prep();
//	cout << seg[1].mx[0] << ' ' << seg[1].mx[1] << endl;
	while (q--) {
		int l, r;
		cin >> l >> r;
		rev(l, r + 1);
		node s = get(l, r + 1);
	/*	cout << " > " << s.mx[0] << " " << s.len[0] << ' ' << s.len[1] << ' ' << s.slen[0] << ' ' << s.slen[1] << ' ' << s.knd[0] << ' ' << s.knd[1] << ' ' << s.sz << " " << s.mx[1] << endl;*/
		cout << s.mx[0] << ' ';
	}
}


//Rohit Rana
#include <bits/stdc++.h>
using namespace std;

#define ll long long

const int mxN=5e5;
int n, q;
string s;

struct node
{
  int len, pre[2], suf[2], ans[2], pre2[2], suf2[2];
}
st[1<<20];

bool lz[1<<20];

node cmb(node l, node r) {
  node a;
  a.len=l.len+r.len;
  for(int k : {0, 1}) {
    a.pre[k]=l.pre[k]==l.len?l.len+r.pre[k]:l.pre[k];
    a.suf[k]=r.suf[k]==r.len?r.len+l.suf[k]:r.suf[k];
    a.ans[k]=max({l.ans[k], r.ans[k], l.suf2[k]+r.pre[k], l.suf[k]+r.pre2[k]});
  }
  for(int k : {0, 1}) {
    a.pre2[k]=l.suf[k]==l.len?l.len+r.pre2[k]:(l.pre2[k]==l.len?l.len+r.pre[k]:l.pre2[k]);
    a.suf2[k]=r.pre[k]==r.len?r.len+l.suf2[k]:(r.suf2[k]==r.len?r.len+l.suf[k]:r.suf2[k]);
  }
  return a;
}

// void pr(int i) {
//   //return;
//   cout << "n " << i << endl;
//   cout << st[i].len << endl;
//   for(int k : {0, 1}) {
//     cout << st[i].pre[k] << " " << st[i].suf[k] << " " << st[i].pre2[k] << " " << st[i].suf2[k] << " " << st[i].ans[k] << endl;
//   }
// }

void bld(int i=1, int l2=0, int r2=n-1)
{
  //debug(i,l2,r2);
  if(l2==r2)
  {
    st[i].len=1;
    int k=s[l2]!='<';
    st[i].pre[k]=1;
    st[i].suf[k^1]=1;
    for(int j : {0, 1})
      st[i].pre2[j]=st[i].suf2[j]=st[i].ans[j]=1;
    // pr(i);
    return;
  }
  int m2=(l2+r2)/2;
  // debug(m2);
  bld(2*i, l2, m2);
  bld(2*i+1, m2+1, r2);
  st[i]=cmb(st[2*i], st[2*i+1]);
  // pr(i);
  //pr(i);
}

void app(int i, bool x) {
  if(x) {
    swap(st[i].pre[0], st[i].pre[1]);
    swap(st[i].suf[0], st[i].suf[1]);
    swap(st[i].pre2[0], st[i].pre2[1]);
    swap(st[i].suf2[0], st[i].suf2[1]);
    swap(st[i].ans[0], st[i].ans[1]);
  }
  lz[i]^=x;
}

void psh(int i) {
  app(2*i, lz[i]);
  app(2*i+1, lz[i]);
  lz[i]=0;
}

void upd(int l1, int r1, int i=1, int l2=0, int r2=n-1)
{
  if(l1<=l2&&r2<=r1)
  {
    app(i, 1);
    return;
  }
  int m2=(l2+r2)/2;
  psh(i);
  if(l1<=m2)
    upd(l1, r1, 2*i, l2, m2);
  if(m2<r1)
    upd(l1, r1, 2*i+1, m2+1, r2);
  st[i]=cmb(st[2*i], st[2*i+1]);
  //pr(i);
}

node qry(int l1, int r1, int i=1, int l2=0, int r2=n-1)
{
  if(l1<=l2&&r2<=r1)
    return st[i];
  int m2=(l2+r2)/2;
  psh(i);
  if(r1<=m2)
    return qry(l1, r1, 2*i, l2, m2);
  if(m2<l1)
    return qry(l1, r1, 2*i+1, m2+1, r2);
  return cmb(qry(l1, r1, 2*i, l2, m2), qry(l1, r1, 2*i+1, m2+1, r2));
}

// void pr2(int i=1, int l2=0, int r2=n-1) {
//   pr(i);
//   if(l2<r2) {
//     int m2=(l2+r2)/2;
//     pr2(2*i, l2, m2);
//     pr2(2*i+1, m2+1, r2);
//   }
// }

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
  #endif
  cin >> n >> q;
  cin>> s;

  bld();

  while(q--)
  {
    int l, r;
    cin >> l >> r, --l, --r;
    upd(l, r);
    //pr2();
    cout << qry(l, r).ans[0] << "\n";
  }
}


#include <bits/stdc++.h>

int ri() {
	int n;
	scanf("%d", &n);
	return n;
}
typedef enum {
	NONE,
	SINGLE,
	DOUBLE
} Type;

struct Payload {
	Type type = NONE;
	int left = 0; // + : inside, including middle
	int right = 0;
	int max = 0;
	Payload () = default;
	Payload (bool flag) {
		type = SINGLE;
		max = 1;
		left = right = flag ? 1 : -1;
	}
	Payload (int type, int left, int right, int max) : type((Type) type), left(left), right(right), max(max) {}
	Payload operator * (const Payload &rhs) {
		if (type == NONE) return rhs;
		if (rhs.type == NONE) return *this;
		if (type == SINGLE && rhs.type == SINGLE) {
			if ((right < 0) == (rhs.left < 0)) {
				int added = right + rhs.left;
				return {SINGLE, added, added, std::abs(added)};
			} else if (right > 0 && rhs.left < 0) return {DOUBLE, left - rhs.right, rhs.right - left, std::abs(left) + std::abs(rhs.right)};
			else return {DOUBLE, left, rhs.right, std::abs(left) + std::abs(rhs.right)};
		}
		if (type == SINGLE) {
			if ((right < 0) == (rhs.left < 0) || (right > 0 && rhs.left < 0))
				return {DOUBLE, right + rhs.left, rhs.right, std::max(rhs.max, std::abs(right) + std::abs(rhs.left))};
			else return {DOUBLE, left, rhs.right, std::max(rhs.max, std::abs(right))};
		}
		if (rhs.type == SINGLE) {
			if ((right < 0) == (rhs.left < 0) || (right > 0 && rhs.left < 0))
				return {DOUBLE, left, right + rhs.left, std::max(max, std::abs(right) + std::abs(rhs.left))};
			else return {DOUBLE, left, rhs.right, std::max(max, std::abs(rhs.right))};
		}
		if ((right < 0) == (rhs.left < 0) || (right > 0 && rhs.left < 0))
			return {DOUBLE, left, rhs.right, std::max({max, rhs.max, std::abs(right) + std::abs(rhs.left)})};
		else return {DOUBLE, left, rhs.right, std::max(max, rhs.max)};
	}
};
struct Payload2 {
	Payload r0, r1;
	Payload2 () = default;
	Payload2 (bool flag) : r0(flag), r1(!flag) {}
	Payload2 (Payload r0, Payload r1) : r0(r0), r1(r1) {}
	Payload2 operator * (const Payload2 &rhs) {
		return {r0 * rhs.r0, r1 * rhs.r1};
	}
	void flip() { std::swap(r0, r1); }
};
struct SegTree {
	int n;
	std::vector<Payload2> data;
	std::vector<bool> flipped;
	SegTree (std::string s) {
		for (n = 1; n < (int) s.size(); n <<= 1);
		data.resize(n << 1);
		for (int i = 0; i < (int) s.size(); i++) data[i + n] = Payload2(s[i] == '>');
		for (int i = n; --i; ) data[i] = data[i << 1] * data[i << 1 | 1];
		flipped.resize(n << 1);
	}
	void flush(int i) {
		if (flipped[i]) {
			data[i].flip();
			if (i < n) flipped[i << 1].flip(), flipped[i << 1 | 1].flip();
			flipped[i] = false;
		}
	}
	template<class T> void dive(int l, int r, int node, int node_l, int node_r, const T &func) {
		flush(node);
		if (r <= node_l || l >= node_r) return;
		if (l <= node_l && r >= node_r) {
			func(node);
		} else {
			int mid = node_l + ((node_r - node_l) >> 1);
			dive(l, r, node << 1, node_l, mid, func);
			dive(l, r, node << 1 | 1, mid, node_r, func);
			data[node] = data[node << 1] * data[node << 1 | 1];
		}
	}
	void flip(int l, int r) {
		dive(l, r, 1, 0, n, [&] (int i) { flipped[i].flip(); flush(i); });
	}
	int max(int l, int r) {
		Payload2 res;
		dive(l, r, 1, 0, n, [&] (int i) { res = res * data[i]; });
		return res.r0.max;
	}
};

int main() {
	int n = ri();
	int q = ri();
	std::string s;
	std::cin >> s;
	SegTree tree(s);

	for (int i = 0; i < q; i++) {
		int l = ri() - 1;
		int r = ri();
		tree.flip(l, r);
		/*
		if (i == q - 1)
	for (int i = 0; i < tree.n * 2; i++) {
		#define cur tree.data[i].r0
		std::cerr << i << " : " << tree.flipped[i] << " " << std::endl;
		std::cerr << "   " << (cur.type == NONE ? "NONE" : cur.type == SINGLE ? "SINGLE" : "DOUBLE") <<
			"  max:" << cur.max << " [" << cur.left << "," << cur.right << "] " << std::endl;
		#undef cur
		#define cur tree.data[i].r1
		std::cerr << "   " << (cur.type == NONE ? "NONE" : cur.type == SINGLE ? "SINGLE" : "DOUBLE") <<
			"  max:" << cur.max << " [" << cur.left << "," << cur.right << "] " << std::endl;
		#undef cur
	}*/

		printf("%d\n", tree.max(l, r));
	}
	return 0;
}


#include <bits/stdc++.h>

int ri() {
	int n;
	scanf("%d", &n);
	return n;
}
typedef enum {
	NONE,
	SINGLE,
	DOUBLE
} Type;

struct Payload {
	Type type = NONE;
	int left = 0;
	int right = 0;
	int max = 0;
	Payload () = default;
	Payload (bool flag) {
		type = SINGLE;
		max = 1;
		left = right = flag ? 1 : -1;
	}
	Payload (int type, int left, int right, int max) : type((Type) type), left(left), right(right), max(max) {}
	Payload operator * (const Payload &rhs) {
		if (type == NONE) return rhs;
		if (rhs.type == NONE) return *this;
		if ((right < 0) == (rhs.left < 0) || (right > 0 && rhs.left < 0)) {
			int added = std::abs(right) + std::abs(rhs.left);
			Type new_type = type == SINGLE && rhs.type == SINGLE ? SINGLE : DOUBLE;
			int new_left = type == SINGLE ? added * (left < 0 ? -1 : 1) : left;
			int new_right = rhs.type == SINGLE ? added * (rhs.right < 0 ? -1 : 1) : rhs.right;
			int new_max = std::max({max, rhs.max, added});
			return {new_type, new_left, new_right, new_max};
		} else return {DOUBLE, left, rhs.right, std::max(max, rhs.max)};
	}
};
struct Payload2 {
	Payload r0, r1;
	Payload2 () = default;
	Payload2 (bool flag) : r0(flag), r1(!flag) {}
	Payload2 (Payload r0, Payload r1) : r0(r0), r1(r1) {}
	Payload2 operator * (const Payload2 &rhs) {
		return {r0 * rhs.r0, r1 * rhs.r1};
	}
	void flip() { std::swap(r0, r1); }
};
struct SegTree {
	int n;
	std::vector<Payload2> data;
	std::vector<bool> flipped;
	SegTree (std::string s) {
		for (n = 1; n < (int) s.size(); n <<= 1);
		data.resize(n << 1);
		for (int i = 0; i < (int) s.size(); i++) data[i + n] = Payload2(s[i] == '>');
		for (int i = n; --i; ) data[i] = data[i << 1] * data[i << 1 | 1];
		flipped.resize(n << 1);
	}
	void flush(int i) {
		if (flipped[i]) {
			data[i].flip();
			if (i < n) flipped[i << 1].flip(), flipped[i << 1 | 1].flip();
			flipped[i] = false;
		}
	}
	template<class T> void dive(int l, int r, int node, int node_l, int node_r, const T &func) {
		flush(node);
		if (r <= node_l || l >= node_r) return;
		if (l <= node_l && r >= node_r) {
			func(node);
		} else {
			int mid = node_l + ((node_r - node_l) >> 1);
			dive(l, r, node << 1, node_l, mid, func);
			dive(l, r, node << 1 | 1, mid, node_r, func);
			data[node] = data[node << 1] * data[node << 1 | 1];
		}
	}
	void flip(int l, int r) {
		dive(l, r, 1, 0, n, [&] (int i) { flipped[i].flip(); flush(i); });
	}
	int max(int l, int r) {
		Payload2 res;
		dive(l, r, 1, 0, n, [&] (int i) { res = res * data[i]; });
		return res.r0.max;
	}
};

int main() {
	int n = ri();
	int q = ri();
	std::string s;
	std::cin >> s;
	SegTree tree(s);
	for (int i = 0; i < q; i++) {
		int l = ri() - 1;
		int r = ri();
		tree.flip(l, r);
		printf("%d\n", tree.max(l, r));
	}
	return 0;
}


#include <bits/stdc++.h>

int ri() {
	int n;
	scanf("%d", &n);
	return n;
}
typedef enum {
	NONE,
	SINGLE,
	DOUBLE
} Type;

struct Payload {
	Type type = NONE;
	int left = 0; // + : inside, including middle
	int right = 0;
	int max = 0;
	Payload () = default;
	Payload (bool flag) {
		type = SINGLE;
		max = 1;
		left = right = flag ? 1 : -1;
	}
	Payload (int type, int left, int right, int max) : type((Type) type), left(left), right(right), max(max) {}
	Payload operator * (const Payload &rhs) {
		if (type == NONE) return rhs;
		if (rhs.type == NONE) return *this;
		if (type == SINGLE && rhs.type == SINGLE) {
			if ((right < 0) == (rhs.left < 0) || (right > 0 && rhs.left < 0)) {
				int added = std::abs(right) + std::abs(rhs.left);
				return {SINGLE, added * (left < 0 ? -1 : 1), added * (rhs.right < 0 ? -1 : 1), added};
			} else return {DOUBLE, left, rhs.right, std::max(max, rhs.max)};
		}
		if (type == SINGLE) {
			if ((right < 0) == (rhs.left < 0) || (right > 0 && rhs.left < 0)) {
				int added = std::abs(right) + std::abs(rhs.left);
				return {DOUBLE, added * (left < 0 ? -1 : 1), rhs.right, std::max(added, rhs.max)};
			} else return {DOUBLE, left, rhs.right, std::max(max, rhs.max)};
		}
		if (rhs.type == SINGLE) {
			if ((right < 0) == (rhs.left < 0) || (right > 0 && rhs.left < 0)) {
				int added = std::abs(right) + std::abs(rhs.left);
				return {DOUBLE, left, added * (rhs.right < 0 ? -1 : 1), std::max(max, added)};
			} else return {DOUBLE, left, rhs.right, std::max(max, rhs.max)};
		}
		if ((right < 0) == (rhs.left < 0) || (right > 0 && rhs.left < 0)) {
			int added = std::abs(right) + std::abs(rhs.left);
			return {DOUBLE, left, rhs.right, std::max({max, rhs.max, added})};
		} else return {DOUBLE, left, rhs.right, std::max(max, rhs.max)};
	}
};
struct Payload2 {
	Payload r0, r1;
	Payload2 () = default;
	Payload2 (bool flag) : r0(flag), r1(!flag) {}
	Payload2 (Payload r0, Payload r1) : r0(r0), r1(r1) {}
	Payload2 operator * (const Payload2 &rhs) {
		return {r0 * rhs.r0, r1 * rhs.r1};
	}
	void flip() { std::swap(r0, r1); }
};
struct SegTree {
	int n;
	std::vector<Payload2> data;
	std::vector<bool> flipped;
	SegTree (std::string s) {
		for (n = 1; n < (int) s.size(); n <<= 1);
		data.resize(n << 1);
		for (int i = 0; i < (int) s.size(); i++) data[i + n] = Payload2(s[i] == '>');
		for (int i = n; --i; ) data[i] = data[i << 1] * data[i << 1 | 1];
		flipped.resize(n << 1);
	}
	void flush(int i) {
		if (flipped[i]) {
			data[i].flip();
			if (i < n) flipped[i << 1].flip(), flipped[i << 1 | 1].flip();
			flipped[i] = false;
		}
	}
	template<class T> void dive(int l, int r, int node, int node_l, int node_r, const T &func) {
		flush(node);
		if (r <= node_l || l >= node_r) return;
		if (l <= node_l && r >= node_r) {
			func(node);
		} else {
			int mid = node_l + ((node_r - node_l) >> 1);
			dive(l, r, node << 1, node_l, mid, func);
			dive(l, r, node << 1 | 1, mid, node_r, func);
			data[node] = data[node << 1] * data[node << 1 | 1];
		}
	}
	void flip(int l, int r) {
		dive(l, r, 1, 0, n, [&] (int i) { flipped[i].flip(); flush(i); });
	}
	int max(int l, int r) {
		Payload2 res;
		dive(l, r, 1, 0, n, [&] (int i) { res = res * data[i]; });
		return res.r0.max;
	}
};

int main() {
	int n = ri();
	int q = ri();
	std::string s;
	std::cin >> s;
	SegTree tree(s);
	/*
	for (int i = 0; i < tree.n * 2; i++) {
		#define cur tree.data[i].r0
		std::cerr << i << " : " << tree.flipped[i] << " " << std::endl;
		std::cerr << "   " << (cur.type == NONE ? "NONE" : cur.type == SINGLE ? "SINGLE" : "DOUBLE") <<
			"  max:" << cur.max << " [" << cur.left << "," << cur.right << "] " << std::endl;
		#undef cur
		#define cur tree.data[i].r1
		std::cerr << "   " << (cur.type == NONE ? "NONE" : cur.type == SINGLE ? "SINGLE" : "DOUBLE") <<
			"  max:" << cur.max << " [" << cur.left << "," << cur.right << "] " << std::endl;
		#undef cur
	}
	*/
	for (int i = 0; i < q; i++) {
		int l = ri() - 1;
		int r = ri();
		tree.flip(l, r);
		/*
		if (i == q - 1)
	for (int i = 0; i < tree.n * 2; i++) {
		#define cur tree.data[i].r0
		std::cerr << i << " : " << tree.flipped[i] << " " << std::endl;
		std::cerr << "   " << (cur.type == NONE ? "NONE" : cur.type == SINGLE ? "SINGLE" : "DOUBLE") <<
			"  max:" << cur.max << " [" << cur.left << "," << cur.right << "] " << std::endl;
		#undef cur
		#define cur tree.data[i].r1
		std::cerr << "   " << (cur.type == NONE ? "NONE" : cur.type == SINGLE ? "SINGLE" : "DOUBLE") <<
			"  max:" << cur.max << " [" << cur.left << "," << cur.right << "] " << std::endl;
		#undef cur
	}*/

		printf("%d\n", tree.max(l, r));
	}
	return 0;
}


#include <iostream>
#define nmax 500000

#include <iostream>
#include <cstdio>
#include <string>
struct cp_istream
{
    cp_istream() = default;
    cp_istream& operator = (const cp_istream&) = delete;
    cp_istream& operator >> (int &x)
    {
        char c;
        int tmp = 0;
        for(c = getchar(); c == ' ' || c == '\n'; c = getchar());
        int sign = 1;
        while(1){
          if(c == '+') c = getchar();
          else if(c == '-'){
            sign = -sign;
            c = getchar();
          }
          else break;
        }
        for(; c != ' ' && c != '\n'; c = getchar())
          tmp = tmp * 10 + c - '0';
        x = (sign == 1) ? tmp : -tmp;
        return *this;
    }
    cp_istream& operator >> (unsigned &x)
    {
        char c;
        unsigned tmp = 0;
        for(c = getchar(); c == ' ' || c == '\n'; c = getchar());
        int sign = 1;
        while(1){
          if(c == '+') c = getchar();
          else if(c == '-'){
            sign = -sign;
            c = getchar();
          }
          else break;
        }
        for(; c != ' ' && c != '\n'; c = getchar())
          tmp = tmp * 10 + c - '0';
        x = (sign == 1) ? tmp : -tmp;
        return *this;
    }
    cp_istream& operator >> (short &x)
    {
        char c;
        short tmp = 0;
        for(c = getchar(); c == ' ' || c == '\n'; c = getchar());
        int sign = 1;
        while(1){
          if(c == '+') c = getchar();
          else if(c == '-'){
            sign = -sign;
            c = getchar();
          }
          else break;
        }
        for(; c != ' ' && c != '\n'; c = getchar())
          tmp = tmp * 10 + c - '0';
        x = (sign == 1) ? tmp : -tmp;
        return *this;
    }
    cp_istream& operator >> (unsigned short &x)
    {
        char c;
        unsigned short tmp = 0;
        for(c = getchar(); c == ' ' || c == '\n'; c = getchar());
        int sign = 1;
        while(1){
          if(c == '+') c = getchar();
          else if(c == '-'){
            sign = -sign;
            c = getchar();
          }
          else break;
        }
        for(; c != ' ' && c != '\n'; c = getchar())
          tmp = tmp * 10 + c - '0';
        x = (sign == 1) ? tmp : -tmp;
        return *this;
    }
    cp_istream& operator >> (long &x)
    {
        char c;
        long tmp = 0;
        for(c = getchar(); c == ' ' || c == '\n'; c = getchar());
        int sign = 1;
        while(1){
          if(c == '+') c = getchar();
          else if(c == '-'){
            sign = -sign;
            c = getchar();
          }
          else break;
        }
        for(; c != ' ' && c != '\n'; c = getchar())
          tmp = tmp * 10 + c - '0';
        x = (sign == 1) ? tmp : -tmp;
        return *this;
    }
    cp_istream& operator >> (unsigned long &x)
    {
        char c;
        unsigned long tmp = 0;
        for(c = getchar(); c == ' ' || c == '\n'; c = getchar());
        int sign = 1;
        while(1){
          if(c == '+') c = getchar();
          else if(c == '-'){
            sign = -sign;
            c = getchar();
          }
          else break;
        }
        for(; c != ' ' && c != '\n'; c = getchar())
          tmp = tmp * 10 + c - '0';
        x = (sign == 1) ? tmp : -tmp;
        return *this;
    }
    cp_istream& operator >> (long long &x)
    {
        char c;
        long long tmp = 0;
        for(c = getchar(); c == ' ' || c == '\n'; c = getchar());
        int sign = 1;
        while(1){
          if(c == '+') c = getchar();
          else if(c == '-'){
            sign = -sign;
            c = getchar();
          }
          else break;
        }
        for(; c != ' ' && c != '\n'; c = getchar())
          tmp = tmp * 10 + c - '0';
        x = (sign == 1) ? tmp : -tmp;
        return *this;
    }
    cp_istream& operator >> (unsigned long long &x)
    {
        char c;
        unsigned long long tmp = 0;
        for(c = getchar(); c == ' ' || c == '\n'; c = getchar());
        int sign = 1;
        while(1){
          if(c == '+') c = getchar();
          else if(c == '-'){
            sign = -sign;
            c = getchar();
          }
          else break;
        }
        for(; c != ' ' && c != '\n'; c = getchar())
          tmp = tmp * 10 + c - '0';
        x = (sign == 1) ? tmp : -tmp;
        return *this;
    }
    cp_istream& operator >> (signed char &x)
    {
        char c;
        signed char tmp = 0;
        for(c = getchar(); c == ' ' || c == '\n'; c = getchar());
        int sign = 1;
        while(1){
          if(c == '+') c = getchar();
          else if(c == '-'){
            sign = -sign;
            c = getchar();
          }
          else break;
        }
        for(; c != ' ' && c != '\n'; c = getchar())
          tmp = tmp * 10 + c - '0';
        x = (sign == 1) ? tmp : -tmp;
        return *this;
    }
    cp_istream& operator >> (unsigned char &x)
    {
        char c;
        unsigned char tmp = 0;
        for(c = getchar(); c == ' ' || c == '\n'; c = getchar());
        int sign = 1;
        while(1){
          if(c == '+') c = getchar();
          else if(c == '-'){
            sign = -sign;
            c = getchar();
          }
          else break;
        }
        for(; c != ' ' && c != '\n'; c = getchar())
          tmp = tmp * 10 + c - '0';
        x = (sign == 1) ? tmp : -tmp;
        return *this;
    }
    cp_istream& operator >> (char &x)
    {
        char c;
        for(c = getchar(); c == ' ' || c == '\n'; c = getchar());
        x = c;
        return *this;
    }
    cp_istream& operator >> (char *x)
    {
        char c;
        for(c = getchar(); c == ' ' || c == '\n'; c = getchar());
        for(; c != ' ' && c != '\n'; c = getchar())
          *(x++) = c;
        *x = 0;
        return *this;
    }
    cp_istream& operator >> (std::string &x)
    {
        x.clear();
        char c;
        for(c = getchar(); c == ' ' || c == '\n'; c = getchar());
        for(; c != ' ' && c != '\n'; c = getchar())
          x.push_back(c);
        return *this;
    }
    template<unsigned Nm>
    cp_istream& operator >> (char (&)[Nm]) = delete;
}cpin;
struct cp_ostream
{
    cp_ostream() = default;
    cp_ostream& operator = (const cp_ostream&) = delete;

    cp_ostream& operator << (int x)
    {
        if(x == 0)
          putchar('0');
        else{
          if(x < 0){
            x = -x;
            putchar('-');
          }
          int y = 0;
          int c = 0;
          while(x){
            ++c;
            y = y * 10 + x % 10;
            x /= 10;
          }
          while(c--){
            putchar(y % 10 + '0');
            y /= 10;
          }
        }
        return *this;
    }
    cp_ostream& operator << (unsigned x)
    {
        if(x == 0)
          putchar('0');
        else{
          if(x < 0){
            x = -x;
            putchar('-');
          }
          unsigned y = 0;
          int c = 0;
          while(x){
            ++c;
            y = y * 10 + x % 10;
            x /= 10;
          }
          while(c--){
            putchar(y % 10 + '0');
            y /= 10;
          }
        }
        return *this;
    }
    cp_ostream& operator << (short x)
    {
        if(x == 0)
          putchar('0');
        else{
          if(x < 0){
            x = -x;
            putchar('-');
          }
          short y = 0;
          int c = 0;
          while(x){
            ++c;
            y = y * 10 + x % 10;
            x /= 10;
          }
          while(c--){
            putchar(y % 10 + '0');
            y /= 10;
          }
        }
        return *this;
    }
    cp_ostream& operator << (unsigned short x)
    {
        if(x == 0)
          putchar('0');
        else{
          if(x < 0){
            x = -x;
            putchar('-');
          }
          unsigned short y = 0;
          int c = 0;
          while(x){
            ++c;
            y = y * 10 + x % 10;
            x /= 10;
          }
          while(c--){
            putchar(y % 10 + '0');
            y /= 10;
          }
        }
        return *this;
    }
    cp_ostream& operator << (long x)
    {
        if(x == 0)
          putchar('0');
        else{
          if(x < 0){
            x = -x;
            putchar('-');
          }
          long y = 0;
          int c = 0;
          while(x){
            ++c;
            y = y * 10 + x % 10;
            x /= 10;
          }
          while(c--){
            putchar(y % 10 + '0');
            y /= 10;
          }
        }
        return *this;
    }
    cp_ostream& operator << (unsigned long x)
    {
        if(x == 0)
          putchar('0');
        else{
          if(x < 0){
            x = -x;
            putchar('-');
          }
          unsigned long y = 0;
          int c = 0;
          while(x){
            ++c;
            y = y * 10 + x % 10;
            x /= 10;
          }
          while(c--){
            putchar(y % 10 + '0');
            y /= 10;
          }
        }
        return *this;
    }
    cp_ostream& operator << (long long x)
    {
        if(x == 0)
          putchar('0');
        else{
          if(x < 0){
            x = -x;
            putchar('-');
          }
          long long y = 0;
          int c = 0;
          while(x){
            ++c;
            y = y * 10 + x % 10;
            x /= 10;
          }
          while(c--){
            putchar(y % 10 + '0');
            y /= 10;
          }
        }
        return *this;
    }
    cp_ostream& operator << (unsigned long long x)
    {
        if(x == 0)
          putchar('0');
        else{
          if(x < 0){
            x = -x;
            putchar('-');
          }
          unsigned long long y = 0;
          int c = 0;
          while(x){
            ++c;
            y = y * 10 + x % 10;
            x /= 10;
          }
          while(c--){
            putchar(y % 10 + '0');
            y /= 10;
          }
        }
        return *this;
    }cp_ostream& operator << (signed char x)
    {
        if(x == 0)
          putchar('0');
        else{
          if(x < 0){
            x = -x;
            putchar('-');
          }
          signed char y = 0;
          int c = 0;
          while(x){
            ++c;
            y = y * 10 + x % 10;
            x /= 10;
          }
          while(c--){
            putchar(y % 10 + '0');
            y /= 10;
          }
        }
        return *this;
    }
    cp_ostream& operator << (unsigned char x)
    {
        if(x == 0)
          putchar('0');
        else{
          if(x < 0){
            x = -x;
            putchar('-');
          }
          unsigned char y = 0;
          int c = 0;
          while(x){
            ++c;
            y = y * 10 + x % 10;
            x /= 10;
          }
          while(c--){
            putchar(y % 10 + '0');
            y /= 10;
          }
        }
        return *this;
    }
    cp_ostream& operator << (char x)
    {
        putchar(x);
        return *this;
    }
    cp_ostream& operator << (const void *x)
    {
        std::cout << x;
        return *this;
    }
    cp_ostream& operator << (const char *x)
    {
        while(*x) putchar(*(x++));
        return *this;
    }
    template<unsigned Nm>
    cp_ostream& operator << (const char (&x)[Nm])
    {
        return operator<<((const char*)x);
    }
    cp_ostream& operator << (const std::string &x)
    {
        return operator<<(x.c_str());
    }
}cpout;

using namespace std;
class node
{
    int len;
    static int max(int a, int b)
    {
        return (a > b) ? a : b;
    }
    struct info
    {
        int l1, l2, r1, r2, ans;
    }c1, c2;
    static info add(const info &lhs, const info &rhs, int lenl, int lenr)
    {
        info res;
        res.ans = max(lhs.ans, rhs.ans);
        if(lhs.r1 == 0) res.ans = max(res.ans, lhs.r2 + rhs.l1 + rhs.l2);
        if(rhs.l1 == 0) res.ans = max(res.ans, rhs.l2 + lhs.r1 + lhs.r2);
        if(lhs.l1 == lenl){
          res.l1 = lenl + rhs.l1;
          res.l2 = rhs.l2;
        }
        else{
          res.l1 = lhs.l1;
          if(rhs.l1 == 0 && lhs.l1 + lhs.l2 == lenl)
            res.l2 = lhs.l2 + rhs.l2;
          else res.l2 = lhs.l2;
        }
        if(rhs.r1 == lenr){
          res.r1 = lenr + lhs.r1;
          res.r2 = lhs.r2;
        }
        else{
          res.r1 = rhs.r1;
          if(lhs.r1 == 0 && rhs.r1 + rhs.r2 == lenr)
            res.r2 = rhs.r2 + lhs.r2;
          else res.r2 = rhs.r2;
        }
        if(lhs.l1 == 0) res.ans = max(res.ans, lhs.l2);
        if(rhs.r1 == 0) res.ans = max(res.ans, rhs.r2);
        return res;
    }
public:
    void operator = (char c)
    {
        len = 1;
        if(c == '<'){
          c1 = {0, 1, 1, 0, 1};
          c2 = {1, 0, 0, 1, 1};
        }
        else{
          c1 = {1, 0, 0, 1, 1};
          c2 = {0, 1, 1, 0, 1};
        }
    }
    void flip()
    {
        info tmp = c1;
        c1 = c2;
        c2 = tmp;
    }
    friend node operator + (const node &lhs, const node &rhs)
    {
        node res;
        res.len = lhs.len + rhs.len;
        res.c1 = add(lhs.c1, rhs.c1, lhs.len, rhs.len);
        res.c2 = add(lhs.c2, rhs.c2, lhs.len, rhs.len);
        return res;
    }
    int ans() const
    {
        return c1.ans;
    }
};

int n, lazy[nmax*4+1], cl, cr, q;
char s[nmax+1];
node smt[nmax*4+1];
void init_(int id, int l, int r)
{
    if(l == r){
      smt[id] = s[l - 1];
      return;
    }
    int mid = (l + r) / 2;
    init_(id * 2, l, mid);
    init_(id * 2 + 1, mid + 1, r);
    smt[id] = smt[id * 2] + smt[id * 2 + 1];
}
void propg(int id, int leaf)
{
    if(!leaf && lazy[id]){
      smt[id * 2].flip();
      smt[id * 2 + 1].flip();
      lazy[id * 2] ^= 1;
      lazy[id * 2 + 1] ^= 1;
    }
    lazy[id] = 0;
}
node upd_(int id, int l, int r)
{
    if(cl <= l && r <= cr){
      smt[id].flip();
      lazy[id] ^= 1;
      propg(id, l == r);
      return smt[id];
    }
    propg(id, 0);
    int mid = (l + r) / 2;
    node vl, vr;
    int stat = 0;
    if(cl <= mid) vl = upd_(id * 2, l, mid), stat += 1;
    if(cr > mid) vr = upd_(id * 2 + 1, mid + 1, r), stat += 2;
    smt[id] = smt[id * 2] + smt[id * 2 + 1];
    if(stat == 1) return vl;
    if(stat == 2) return vr;
    return vl + vr;
}
node upd(int l, int r)
{
    cl = l, cr = r;
    return upd_(1, 1, n);
}
void init()
{
    init_(1, 1, n);
}
int main()
{
    cpin >> n >> q >> s;
    init();
    for(int i = 1; i <= q; ++i){
      int l, r;
      cpin >> l >> r;
      cpout << upd(l, r).ans() << '\n';
    }
    return 0;
}


#include<iostream>
#include<sstream>
#include<fstream>
#include<iomanip>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<queue>
#include<stack>
#include<vector>
#include<string>
#include<map>
#include<set>
#include<ctime>
#include<bitset>
#include<iterator>
#define bug cout<<"-----------"<<endl;
#define ll  long long
#define ull unsigned long long
using namespace std;
const int N=1e6+5,M=1e9+7;
const ull base=13331;
const double Pi=acos(-1.0);
const ll C=299792458;
const int inf=0x3f3f3f3f;
inline int read() {
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
int a[N];
struct node{
	/*
		l 	<<<<
		r 	>>>>
		lr 	<<>>
		rl	>><<
	*/
	int l,r;
	int pl,pr,plr,prl;
	int sl,sr,slr,srl;
	int maxlr,maxrl;
	int rev;
	void rever(){
		swap(pl,pr),swap(plr,prl);
		swap(sl,sr),swap(slr,srl);
		swap(maxrl,maxlr);
	}
	node operator +(const node &b)const{
		node c;c.rev=0;
		c.l=l,c.r=b.r;

		if(r-l+1==plr){
			c.plr=plr+b.pr;
			if(plr==pl)
				c.plr=plr+b.plr;
		}
		else c.plr=plr;
		if(r-l+1==prl){
			c.prl=prl+b.pl;
			if(prl==pr)
				c.prl=prl+b.prl;
		}
		else c.prl=prl;
		if(b.r-b.l+1==b.slr){
			c.slr=b.slr+sl;
			if(b.slr==b.sr)
				c.slr=slr+b.slr;
		}
		else c.slr=b.slr;
		if(b.r-b.l+1==b.srl){
			c.srl=b.srl+sr;
			if(b.srl==b.sl)
				c.srl=srl+b.srl;
		}
		else c.srl=b.srl;

		if(r-l+1==pl){
			c.pl=pl+b.pl;
			//c.plr=pl+b.plr;
		}
		else c.pl=pl;
		if(r-l+1==pr){
			c.pr=pr+b.pr;
			//c.prl=pr+b.prl;
		}
		else c.pr=pr;
		if(b.r-b.l+1==b.sl){
			c.sl=b.sl+sl;
			//c.srl=srl+b.sl;
		}
		else c.sl=b.sl;
		if(b.r-b.l+1==b.sr){
			c.sr=b.sr+sr;
			//c.slr=slr+b.sr;
		}
		else c.sr=b.sr;
		c.maxlr=max(maxlr,max(b.maxlr,max(c.plr,c.slr)));
		c.maxlr=max(c.maxlr,max(sl+b.pr,max(slr+b.pr,sl+b.plr)));
		c.maxrl=max(maxrl,max(b.maxrl,max(c.prl,c.srl)));
		c.maxrl=max(c.maxrl,max(sr+b.pl,max(srl+b.pl,sr+b.prl)));
		return c;
	}
}t[N*4];
void spread(int p){
	if(t[p].rev){
		t[p].rev=0;
		t[p*2].rev^=1,t[p*2+1].rev^=1;
		t[p].rever();
	}
}
void build(int p,int l,int r){
	t[p].l=l,t[p].r=r;
	if(l==r){
		//cout<<t[p].rev<<endl;
		t[p].maxlr=t[p].maxrl=1;
		t[p].pl=1,t[p].pr=0;
		t[p].plr=t[p].prl=1;
		t[p].sl=1,t[p].sr=0;
		t[p].slr=t[p].srl=1;
		if(a[l])t[p].rever();
		return;
	}
	int mid=((l+r)>>1);
	build(p<<1,l,mid);
	build(p<<1|1,mid+1,r);
	t[p]=t[p<<1]+t[p<<1|1];
}
void change(int p,int l,int r){
	if(l<=t[p].l&&t[p].r<=r){
		t[p].rever();
		t[p].rev^=1;
		t[p<<1].rev^=1;
		t[p<<1|1].rev^=1;
		return;
	}
	spread(p);
	int mid=(t[p].l+t[p].r)/2;
	if(l<=mid)change(p<<1,l,r);
	if(mid+1<=r)change(p<<1|1,l,r);
	t[p]=t[p<<1]+t[p<<1|1];
}
node ask(int p,int l,int r){
	if(l<=t[p].l&&t[p].r<=r){
		return t[p];
	}
	spread(p);
	int mid=(t[p].l+t[p].r)>>1;
	if(r<=mid)return ask(p<<1,l,r);
	if(l>=mid+1)return ask(p<<1|1,l,r);
	return ask(p<<1,l,r)+ask(p<<1|1,l,r);
}
int main(){
    ios::sync_with_stdio(false);
    int n,q;cin>>n>>q;
    string s;cin>>s;
    for(int i=1;i<=n;i++){
    	if(s[i-1]=='<')a[i]=0;
    	else a[i]=1;
    }
    build(1,1,n);
    while(q--){
    	int l,r;
    	cin>>l>>r;
    	//cout<<ask(1,1,n).pr<<endl;
    	change(1,l,r);
    	node c=t[1];
    	//cout<<c.maxrl<<' '<<c.maxlr<<' '<<c.prl<<' '<<c.plr<<' '<<c.srl<<' '<<c.slr<<endl;
    	node ans=ask(1,l,r);
    	cout<<ans.maxrl<<endl;
    }
}


#include<iostream>
#include<sstream>
#include<fstream>
#include<iomanip>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<queue>
#include<stack>
#include<vector>
#include<string>
#include<map>
#include<set>
#include<ctime>
#include<bitset>
#include<iterator>
#define bug cout<<"-----------"<<endl;
#define ll  long long
#define ull unsigned long long
using namespace std;
const int N=1e6+5,M=1e9+7;
const ull base=13331;
const double Pi=acos(-1.0);
const ll C=299792458;
const int inf=0x3f3f3f3f;
inline int read() {
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
int a[N];
struct node{
	/*
		l 	<<<<
		r 	>>>>
		lr 	<<>>
		rl	>><<
	*/
	int l,r;
	int pl,pr,plr,prl;
	int sl,sr,slr,srl;
	int maxlr,maxrl;
	int rev;
	void rever(){
		swap(pl,pr),swap(plr,prl);
		swap(sl,sr),swap(slr,srl);
		swap(maxrl,maxlr);
	}
	node operator +(const node &b)const{
		node c;c.rev=0;
		c.l=l,c.r=b.r;

		if(r-l+1==plr){
			c.plr=plr+b.pr;
			if(plr==pl)
				c.plr=plr+b.plr;
		}
		else c.plr=plr;
		if(r-l+1==prl){
			c.prl=prl+b.pl;
			if(prl==pr)
				c.prl=prl+b.prl;
		}
		else c.prl=prl;
		if(b.r-b.l+1==b.slr){
			c.slr=b.slr+sl;
			if(b.slr==b.sr)
				c.slr=slr+b.slr;
		}
		else c.slr=b.slr;
		if(b.r-b.l+1==b.srl){
			c.srl=b.srl+sr;
			if(b.srl==b.sl)
				c.srl=srl+b.srl;
		}
		else c.srl=b.srl;

		if(r-l+1==pl){
			c.pl=pl+b.pl;
			//c.plr=pl+b.plr;
		}
		else c.pl=pl;
		if(r-l+1==pr){
			c.pr=pr+b.pr;
			//c.prl=pr+b.prl;
		}
		else c.pr=pr;
		if(b.r-b.l+1==b.sl){
			c.sl=b.sl+sl;
			//c.srl=srl+b.sl;
		}
		else c.sl=b.sl;
		if(b.r-b.l+1==b.sr){
			c.sr=b.sr+sr;
			//c.slr=slr+b.sr;
		}
		else c.sr=b.sr;
		c.maxlr=max(maxlr,max(b.maxlr,max(c.plr,c.slr)));
		c.maxlr=max(c.maxlr,max(sl+b.pr,max(slr+b.pr,sl+b.plr)));
		c.maxrl=max(maxrl,max(b.maxrl,max(c.prl,c.srl)));
		c.maxrl=max(c.maxrl,max(sr+b.pl,max(srl+b.pl,sr+b.prl)));
		return c;
	}
}t[N*4];
void spread(int p){
	if(t[p].rev){
		t[p].rev=0;
		t[p*2].rev^=1,t[p*2+1].rev^=1;
		t[p].rever();
	}
}
void build(int p,int l,int r){
	t[p].l=l,t[p].r=r;
	if(l==r){
		//cout<<t[p].rev<<endl;
		t[p].maxlr=t[p].maxrl=1;
		t[p].pl=1,t[p].pr=0;
		t[p].plr=t[p].prl=1;
		t[p].sl=1,t[p].sr=0;
		t[p].slr=t[p].srl=1;
		if(a[l])t[p].rever();
		return;
	}
	int mid=((l+r)>>1);
	build(p<<1,l,mid);
	build(p<<1|1,mid+1,r);
	t[p]=t[p<<1]+t[p<<1|1];
}
void change(int p,int l,int r){
	if(l<=t[p].l&&t[p].r<=r){
		t[p].rever();
		//t[p].rev^=1;
		t[p<<1].rev^=1;
		t[p<<1|1].rev^=1;
		return;
	}
	spread(p);
	int mid=(t[p].l+t[p].r)/2;
	if(l<=mid)change(p<<1,l,r);
	if(mid+1<=r)change(p<<1|1,l,r);
	t[p]=t[p<<1]+t[p<<1|1];
}
node ask(int p,int l,int r){
	if(l<=t[p].l&&t[p].r<=r){
		return t[p];
	}
	spread(p);
	int mid=(t[p].l+t[p].r)>>1;
	if(r<=mid)return ask(p<<1,l,r);
	if(l>=mid+1)return ask(p<<1|1,l,r);
	return ask(p<<1,l,r)+ask(p<<1|1,l,r);
}
int main(){
    ios::sync_with_stdio(false);
    int n,q;cin>>n>>q;
    string s;cin>>s;
    for(int i=1;i<=n;i++){
    	if(s[i-1]=='<')a[i]=0;
    	else a[i]=1;
    }
    build(1,1,n);
    while(q--){
    	int l,r;
    	cin>>l>>r;
    	//cout<<ask(1,1,n).pr<<endl;
    	change(1,l,r);
    	node c=t[1];
    	//cout<<c.maxrl<<' '<<c.maxlr<<' '<<c.prl<<' '<<c.plr<<' '<<c.srl<<' '<<c.slr<<endl;
    	node ans=ask(1,l,r);
    	cout<<ans.maxrl<<endl;
    }
}


#include<iostream>
#include<sstream>
#include<fstream>
#include<iomanip>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<queue>
#include<stack>
#include<vector>
#include<string>
#include<map>
#include<set>
#include<ctime>
#include<bitset>
#include<iterator>
#define bug cout<<"-----------"<<endl;
#define ll  long long
#define ull unsigned long long
using namespace std;
const int N=1e6+5,M=1e9+7;
const ull base=13331;
const double Pi=acos(-1.0);
const ll C=299792458;
const int inf=0x3f3f3f3f;
inline int read() {
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
int a[N];
struct node{
	/*
		l 	<<<<
		r 	>>>>
		lr 	<<>>
		rl	>><<
	*/
	int l,r;
	int pl,pr,plr,prl;
	int sl,sr,slr,srl;
	int maxlr,maxrl;
	int rev;
	void rever(){
		swap(pl,pr),swap(plr,prl);
		swap(sl,sr),swap(slr,srl);
		rev=0;swap(maxrl,maxlr);
	}
	node operator +(const node &b)const{
		node c;c.rev=0;
		c.l=l,c.r=b.r;
		if(r-l+1==pl){
			c.pl=pl+b.pl;
		}
		else c.pl=pl;
		if(r-l+1==pr){
			c.pr=pr+b.pr;
		}
		else c.pr=pr;
		if(r-l+1==plr){
			c.plr=plr+b.pr;
		}
		else c.plr=plr;
		if(r-l+1==prl){
			c.prl=prl+b.pl;
		}
		else c.prl=prl;

		if(b.r-b.l+1==b.sl){
			c.sl=b.sl+sl;
		}
		else c.sl=b.sl;
		if(b.r-b.l+1==b.sr){
			c.sr=b.sr+sr;
		}
		else c.sr=b.sr;
		if(b.r-b.l+1==b.slr){
			c.slr=b.slr+sl;
		}
		else c.slr=b.slr;
		if(b.r-b.l+1==b.srl){
			c.srl=b.srl+sr;
		}
		else c.srl=b.srl;

		c.maxlr=max(maxlr,max(b.maxlr,max(c.plr,c.slr)));
		c.maxlr=max(c.maxlr,max(sl+b.pr,max(slr+b.pr,sl+b.plr)));
		c.maxrl=max(maxrl,max(b.maxrl,max(c.prl,c.srl)));
		c.maxrl=max(c.maxrl,max(sr+b.pl,max(srl+b.pl,sr+b.prl)));
		return c;
	}
}t[N*4];
void spread(int p){
	if(t[p].rev){
		t[p*2].rev^=1,t[p*2+1].rev^=1;
		t[p].rever();
	}
}
void build(int p,int l,int r){
	t[p].l=l,t[p].r=r;
	if(l==r){
		t[p].maxlr=t[p].maxrl=1;
		t[p].pl=1,t[p].pr=0;
		t[p].plr=t[p].prl=1;
		t[p].sl=1,t[p].sr=0;
		t[p].slr=t[p].srl=1;
		if(a[l])t[p].rever();
		return;
	}
	int mid=((l+r)>>1);
	build(p<<1,l,mid);
	build(p<<1|1,mid+1,r);
	t[p]=t[p<<1]+t[p<<1|1];
}
void change(int p,int l,int r){
	if(l<=t[p].l&&t[p].r<=r){
		t[p].rever();
		t[p<<1].rev^=1;
		t[p<<1|1].rev^=1;
		return;
	}
	int mid=(t[p].l+t[p].r)/2;
	if(l<=mid)change(p<<1,l,r);
	if(mid+1<=r)change(p<<1|1,l,r);
	t[p]=t[p<<1]+t[p<<1|1];
}
node ask(int p,int l,int r){
	if(l<=t[p].l&&t[p].r<=r){
		return t[p];
	}
	spread(p);
	int mid=(t[p].l+t[p].r)>>1;
	if(r<=mid)return ask(p<<1,l,r);
	if(l>=mid+1)return ask(p<<1|1,l,r);
	return ask(p<<1,l,r)+ask(p<<1|1,l,r);
}
int main(){
    ios::sync_with_stdio(false);
    int n,q;cin>>n>>q;
    string s;cin>>s;
    for(int i=1;i<=n;i++){
    	if(s[i-1]=='<')a[i]=0;
    	else a[i]=1;
    }
    build(1,1,n);
    while(q--){
    	int l,r;
    	cin>>l>>r;
    	//cout<<ask(1,1,n).pr<<endl;
    	change(1,l,r);
    	node c=t[1];
    	//cout<<c.maxrl<<' '<<c.maxlr<<' '<<c.prl<<' '<<c.plr<<' '<<c.srl<<' '<<c.slr<<endl;
    	node ans=ask(1,l,r);
    	cout<<ans.maxrl<<endl;
    }
}


#include<iostream>
#include<sstream>
#include<fstream>
#include<iomanip>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<queue>
#include<stack>
#include<vector>
#include<string>
#include<map>
#include<set>
#include<ctime>
#include<bitset>
#include<iterator>
#define bug cout<<"-----------"<<endl;
#define ll  long long
#define ull unsigned long long
using namespace std;
const int N=1e6+5,M=1e9+7;
const ull base=13331;
const double Pi=acos(-1.0);
const ll C=299792458;
const int inf=0x3f3f3f3f;
inline int read() {
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
int a[N];
struct node{
	/*
		l 	<<<<
		r 	>>>>
		lr 	<<>>
		rl	>><<
	*/
	int l,r;
	int pl,pr,plr,prl;
	int sl,sr,slr,srl;
	int maxlr,maxrl;
	int rev;
	void rever(){
		swap(pl,pr),swap(plr,prl);
		swap(sl,sr),swap(slr,srl);
		swap(maxrl,maxlr);
	}
	node operator +(const node &b)const{
		node c;c.rev=0;
		c.l=l,c.r=b.r;

		if(r-l+1==plr){
			c.plr=plr+b.pr;
			if(plr==pl)
				c.plr=plr+b.plr;
		}
		else c.plr=plr;
		if(r-l+1==prl){
			c.prl=prl+b.pl;
			if(prl==pr)
				c.prl=prl+b.prl;
		}
		else c.prl=prl;
		if(b.r-b.l+1==b.slr){
			c.slr=b.slr+sl;
			if(b.slr==b.sr)
				c.slr=slr+b.slr;
		}
		else c.slr=b.slr;
		if(b.r-b.l+1==b.srl){
			c.srl=b.srl+sr;
			if(b.srl==b.sl)
				c.srl=srl+b.srl;
		}
		else c.srl=b.srl;

		if(r-l+1==pl){
			c.pl=pl+b.pl;
			//c.plr=pl+b.plr;
		}
		else c.pl=pl;
		if(r-l+1==pr){
			c.pr=pr+b.pr;
			//c.prl=pr+b.prl;
		}
		else c.pr=pr;
		if(b.r-b.l+1==b.sl){
			c.sl=b.sl+sl;
			//c.srl=srl+b.sl;
		}
		else c.sl=b.sl;
		if(b.r-b.l+1==b.sr){
			c.sr=b.sr+sr;
			//c.slr=slr+b.sr;
		}
		else c.sr=b.sr;
		c.maxlr=max(maxlr,max(b.maxlr,max(c.plr,c.slr)));
		c.maxlr=max(c.maxlr,max(sl+b.pr,max(slr+b.pr,sl+b.plr)));
		c.maxrl=max(maxrl,max(b.maxrl,max(c.prl,c.srl)));
		c.maxrl=max(c.maxrl,max(sr+b.pl,max(srl+b.pl,sr+b.prl)));
		return c;
	}
}t[N*4];
void spread(int p){
	if(t[p].rev){
		t[p].rev^=1,t[p*2].rev^=1,t[p*2+1].rev^=1;
		t[p].rever(),t[p*2].rever(),t[p*2+1].rever();
	}
}
void build(int p,int l,int r){
	t[p].l=l,t[p].r=r;
	if(l==r){
		//cout<<t[p].rev<<endl;
		t[p].maxlr=t[p].maxrl=1;
		t[p].pl=1,t[p].pr=0;
		t[p].plr=t[p].prl=1;
		t[p].sl=1,t[p].sr=0;
		t[p].slr=t[p].srl=1;
		if(a[l])t[p].rever();
		return;
	}
	int mid=((l+r)>>1);
	build(p<<1,l,mid);
	build(p<<1|1,mid+1,r);
	t[p]=t[p<<1]+t[p<<1|1];
}
void change(int p,int l,int r){
	if(l<=t[p].l&&t[p].r<=r){
		t[p].rever();t[p].rev^=1;
		//t[p<<1].rev^=1;
		//t[p<<1|1].rev^=1;
		return;
	}
	spread(p);
	int mid=(t[p].l+t[p].r)/2;
	if(l<=mid)change(p<<1,l,r);
	if(mid+1<=r)change(p<<1|1,l,r);
	t[p]=t[p<<1]+t[p<<1|1];
}
node ask(int p,int l,int r){
	if(l<=t[p].l&&t[p].r<=r){
		return t[p];
	}
	spread(p);
	int mid=(t[p].l+t[p].r)>>1;
	if(r<=mid)return ask(p<<1,l,r);
	if(l>=mid+1)return ask(p<<1|1,l,r);
	return ask(p<<1,l,r)+ask(p<<1|1,l,r);
}
int main(){
    ios::sync_with_stdio(false);
    int n,q;cin>>n>>q;
    string s;cin>>s;
    for(int i=1;i<=n;i++){
    	if(s[i-1]=='<')a[i]=0;
    	else a[i]=1;
    }
    build(1,1,n);
    while(q--){
    	int l,r;
    	cin>>l>>r;
    	//cout<<ask(1,1,n).pr<<endl;
    	change(1,l,r);
    	node c=t[1];
    	//cout<<c.maxrl<<' '<<c.maxlr<<' '<<c.prl<<' '<<c.plr<<' '<<c.srl<<' '<<c.slr<<endl;
    	node ans=ask(1,l,r);
    	cout<<ans.maxrl<<endl;
    }
}


#include<iostream>
#include<sstream>
#include<fstream>
#include<iomanip>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<queue>
#include<stack>
#include<vector>
#include<string>
#include<map>
#include<set>
#include<ctime>
#include<bitset>
#include<iterator>
#define bug cout<<"-----------"<<endl;
#define ll  long long
#define ull unsigned long long
using namespace std;
const int N=5e5+5,M=1e9+7;
const ull base=13331;
const double Pi=acos(-1.0);
const ll C=299792458;
const int inf=0x3f3f3f3f;
inline int read() {
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
int a[N];
struct node{
	/*
		l 	<<<<
		r 	>>>>
		lr 	<<>>
		rl	>><<
	*/
	int l,r;
	int pl,pr,plr,prl;
	int sl,sr,slr,srl;
	int maxlr,maxrl;
	int rev;
	void rever(){
		swap(pl,pr),swap(plr,prl);
		swap(sl,sr),swap(slr,srl);
		rev=0;swap(maxrl,maxlr);
	}
	node operator +(const node &b)const{
		node c;c.rev=0;
		c.l=l,c.r=b.r;
		if(r-l+1==pl){
			c.pl=pl+b.pl;
		}
		else c.pl=pl;
		if(r-l+1==pr){
			c.pr=pr+b.pr;
		}
		else c.pr=pr;
		if(r-l+1==plr){
			c.plr=plr+b.pr;
		}
		else c.plr=plr;
		if(r-l+1==prl){
			c.prl=prl+b.pl;
		}
		else c.prl=prl;

		if(b.r-b.l+1==b.sl){
			c.sl=b.sl+sl;
		}
		else c.sl=b.sl;
		if(b.r-b.l+1==b.sr){
			c.sr=b.sr+sr;
		}
		else c.sr=b.sr;
		if(b.r-b.l+1==b.slr){
			c.slr=b.slr+sl;
		}
		else c.slr=b.slr;
		if(b.r-b.l+1==b.srl){
			c.srl=b.srl+sr;
		}
		else c.srl=b.srl;

		c.maxlr=max(maxlr,max(b.maxlr,max(c.plr,c.slr)));
		c.maxlr=max(c.maxlr,max(sl+b.pr,max(slr+b.pr,sl+b.plr)));
		c.maxrl=max(maxrl,max(b.maxrl,max(c.prl,c.srl)));
		c.maxrl=max(c.maxrl,max(sr+b.pl,max(srl+b.pl,sr+b.prl)));
		return c;
	}
}t[N*4];
void spread(int p){
	if(t[p].rev){
		t[p*2].rev^=1,t[p*2+1].rev^=1;
		t[p].rever();
	}
}
void build(int p,int l,int r){
	t[p].l=l,t[p].r=r;
	if(l==r){
		t[p].maxlr=t[p].maxrl=1;
		t[p].pl=1,t[p].pr=0;
		t[p].plr=t[p].prl=1;
		t[p].sl=1,t[p].sr=0;
		t[p].slr=t[p].srl=1;
		if(a[l])t[p].rever();
		return;
	}
	int mid=((l+r)>>1);
	build(p<<1,l,mid);
	build(p<<1|1,mid+1,r);
	t[p]=t[p<<1]+t[p<<1|1];
}
void change(int p,int l,int r){
	if(l<=t[p].l&&t[p].r<=r){
		t[p].rever();
		t[p<<1].rev^=1;
		t[p<<1|1].rev^=1;
		return;
	}
	int mid=(t[p].l+t[p].r)/2;
	if(l<=mid)change(p<<1,l,r);
	if(mid+1<=r)change(p<<1|1,l,r);
	t[p]=t[p<<1]+t[p<<1|1];
}
node ask(int p,int l,int r){
	if(l<=t[p].l&&t[p].r<=r){
		return t[p];
	}
	spread(p);
	int mid=(t[p].l+t[p].r)>>1;
	if(r<=mid)return ask(p<<1,l,r);
	if(l>=mid+1)return ask(p<<1|1,l,r);
	return ask(p<<1,l,r)+ask(p<<1|1,l,r);
}
int main(){
    ios::sync_with_stdio(false);
    int n,q;cin>>n>>q;
    string s;cin>>s;
    for(int i=1;i<=n;i++){
    	if(s[i-1]=='<')a[i]=0;
    	else a[i]=1;
    }
    build(1,1,n);
    while(q--){
    	int l,r;
    	cin>>l>>r;
    	//cout<<ask(1,1,n).pr<<endl;
    	change(1,l,r);
    	node c=t[1];
    	//cout<<c.maxrl<<' '<<c.maxlr<<' '<<c.prl<<' '<<c.plr<<' '<<c.srl<<' '<<c.slr<<endl;
    	node ans=ask(1,l,r);
    	cout<<ans.maxrl<<endl;
    }
}


#include<iostream>
#include<sstream>
#include<fstream>
#include<iomanip>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<queue>
#include<stack>
#include<vector>
#include<string>
#include<map>
#include<set>
#include<ctime>
#include<bitset>
#include<iterator>
#define bug cout<<"-----------"<<endl;
#define ll  long long
#define ull unsigned long long
using namespace std;
const int N=1e6+5,M=1e9+7;
const ull base=13331;
const double Pi=acos(-1.0);
const ll C=299792458;
const int inf=0x3f3f3f3f;
inline int read() {
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
int a[N];
struct node{
	/*
		l 	<<<<
		r 	>>>>
		lr 	<<>>
		rl	>><<
	*/
	int l,r;
	int pl,pr,plr,prl;
	int sl,sr,slr,srl;
	int maxlr,maxrl;
	int rev;
	void rever(){
		swap(pl,pr),swap(plr,prl);
		swap(sl,sr),swap(slr,srl);
		rev=0;swap(maxrl,maxlr);
	}
	node operator +(const node &b)const{
		node c;c.rev=0;
		c.l=l,c.r=b.r;

		if(r-l+1==plr){
			c.plr=plr+b.pr;
		}
		else c.plr=plr;
		if(r-l+1==prl){
			c.prl=prl+b.pl;
		}
		else c.prl=prl;
		if(r-l+1==pl){
			c.pl=pl+b.pl;
			c.plr=pl+b.plr;
		}
		else c.pl=pl;
		if(r-l+1==pr){
			c.pr=pr+b.pr;
			c.prl=pr+b.prl;
		}
		else c.pr=pr;

		if(b.r-b.l+1==b.slr){
			c.slr=b.slr+sl;
		}
		else c.slr=b.slr;
		if(b.r-b.l+1==b.srl){
			c.srl=b.srl+sr;
		}
		else c.srl=b.srl;
		if(b.r-b.l+1==b.sl){
			c.sl=b.sl+sl;
			c.srl=srl+b.sl;
		}
		else c.sl=b.sl;
		if(b.r-b.l+1==b.sr){
			c.sr=b.sr+sr;
			c.slr=slr+b.sr;
		}
		else c.sr=b.sr;
		c.maxlr=max(maxlr,max(b.maxlr,max(c.plr,c.slr)));
		c.maxlr=max(c.maxlr,max(sl+b.pr,max(slr+b.pr,sl+b.plr)));
		c.maxrl=max(maxrl,max(b.maxrl,max(c.prl,c.srl)));
		c.maxrl=max(c.maxrl,max(sr+b.pl,max(srl+b.pl,sr+b.prl)));
		return c;
	}
}t[N*4];
void spread(int p){
	if(t[p].rev){
		t[p*2].rev^=1,t[p*2+1].rev^=1;
		t[p].rever();
	}
}
void build(int p,int l,int r){
	t[p].l=l,t[p].r=r;
	if(l==r){
		t[p].maxlr=t[p].maxrl=1;
		t[p].pl=1,t[p].pr=0;
		t[p].plr=t[p].prl=1;
		t[p].sl=1,t[p].sr=0;
		t[p].slr=t[p].srl=1;
		if(a[l])t[p].rever();
		return;
	}
	int mid=((l+r)>>1);
	build(p<<1,l,mid);
	build(p<<1|1,mid+1,r);
	t[p]=t[p<<1]+t[p<<1|1];
}
void change(int p,int l,int r){
	if(l<=t[p].l&&t[p].r<=r){
		t[p].rever();
		t[p<<1].rev^=1;
		t[p<<1|1].rev^=1;
		return;
	}
	spread(p);
	int mid=(t[p].l+t[p].r)/2;
	if(l<=mid)change(p<<1,l,r);
	if(mid+1<=r)change(p<<1|1,l,r);
	t[p]=t[p<<1]+t[p<<1|1];
}
node ask(int p,int l,int r){
	if(l<=t[p].l&&t[p].r<=r){
		return t[p];
	}
	spread(p);
	int mid=(t[p].l+t[p].r)>>1;
	if(r<=mid)return ask(p<<1,l,r);
	if(l>=mid+1)return ask(p<<1|1,l,r);
	return ask(p<<1,l,r)+ask(p<<1|1,l,r);
}
int main(){
    ios::sync_with_stdio(false);
    int n,q;cin>>n>>q;
    string s;cin>>s;
    for(int i=1;i<=n;i++){
    	if(s[i-1]=='<')a[i]=0;
    	else a[i]=1;
    }
    build(1,1,n);
    while(q--){
    	int l,r;
    	cin>>l>>r;
    	//cout<<ask(1,1,n).pr<<endl;
    	change(1,l,r);
    	node c=t[1];
    	//cout<<c.maxrl<<' '<<c.maxlr<<' '<<c.prl<<' '<<c.plr<<' '<<c.srl<<' '<<c.slr<<endl;
    	node ans=ask(1,l,r);
    	cout<<ans.maxrl<<endl;
    }
}


#include<iostream>
#include<sstream>
#include<fstream>
#include<iomanip>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<queue>
#include<stack>
#include<vector>
#include<string>
#include<map>
#include<set>
#include<ctime>
#include<bitset>
#include<iterator>
#define bug cout<<"-----------"<<endl;
#define ll  long long
#define ull unsigned long long
using namespace std;
const int N=1e6+5,M=1e9+7;
const ull base=13331;
const double Pi=acos(-1.0);
const ll C=299792458;
const int inf=0x3f3f3f3f;
inline int read() {
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
int a[N];
struct node{
	/*
		l 	<<<<
		r 	>>>>
		lr 	<<>>
		rl	>><<
	*/
	int l,r;
	int pl,pr,plr,prl;
	int sl,sr,slr,srl;
	int maxlr,maxrl;
	int rev;
	void rever(){
		swap(pl,pr),swap(plr,prl);
		swap(sl,sr),swap(slr,srl);
		swap(maxrl,maxlr);
	}
	node operator +(const node &b)const{
		node c;c.rev=0;
		c.l=l,c.r=b.r;

		if(r-l+1==plr){
			c.plr=plr+b.pr;
			if(plr==pl)
				c.plr=plr+b.plr;
		}
		else c.plr=plr;
		if(r-l+1==prl){
			c.prl=prl+b.pl;
			if(prl==pr)
				c.prl=prl+b.prl;
		}
		else c.prl=prl;
		if(b.r-b.l+1==b.slr){
			c.slr=b.slr+sl;
			if(b.slr==b.sr)
				c.slr=slr+b.slr;
		}
		else c.slr=b.slr;
		if(b.r-b.l+1==b.srl){
			c.srl=b.srl+sr;
			if(b.srl==b.sl)
				c.srl=srl+b.srl;
		}
		else c.srl=b.srl;

		if(r-l+1==pl){
			c.pl=pl+b.pl;
			//c.plr=pl+b.plr;
		}
		else c.pl=pl;
		if(r-l+1==pr){
			c.pr=pr+b.pr;
			//c.prl=pr+b.prl;
		}
		else c.pr=pr;
		if(b.r-b.l+1==b.sl){
			c.sl=b.sl+sl;
			//c.srl=srl+b.sl;
		}
		else c.sl=b.sl;
		if(b.r-b.l+1==b.sr){
			c.sr=b.sr+sr;
			//c.slr=slr+b.sr;
		}
		else c.sr=b.sr;
		c.maxlr=max(maxlr,max(b.maxlr,max(c.plr,c.slr)));
		c.maxlr=max(c.maxlr,max(sl+b.pr,max(slr+b.pr,sl+b.plr)));
		c.maxrl=max(maxrl,max(b.maxrl,max(c.prl,c.srl)));
		c.maxrl=max(c.maxrl,max(sr+b.pl,max(srl+b.pl,sr+b.prl)));
		return c;
	}
}t[N*4];
void spread(int p){
	if(t[p].rev){
		t[p].rev=0;t[p].rever();
		t[p*2].rev^=1,t[p*2+1].rev^=1;
		//t[p*2].rever(),t[p*2+1].rever();
	}
}
void build(int p,int l,int r){
	t[p].l=l,t[p].r=r;
	if(l==r){
		//cout<<t[p].rev<<endl;
		t[p].maxlr=t[p].maxrl=1;
		t[p].pl=1,t[p].pr=0;
		t[p].plr=t[p].prl=1;
		t[p].sl=1,t[p].sr=0;
		t[p].slr=t[p].srl=1;
		if(a[l])t[p].rever();
		return;
	}
	int mid=((l+r)>>1);
	build(p<<1,l,mid);
	build(p<<1|1,mid+1,r);
	t[p]=t[p<<1]+t[p<<1|1];
}
void change(int p,int l,int r){
	if(l<=t[p].l&&t[p].r<=r){
		t[p].rever();
		//t[p].rev^=1;
		t[p<<1].rev^=1;
		t[p<<1|1].rev^=1;
		return;
	}
	spread(p);
	int mid=(t[p].l+t[p].r)/2;
	if(l<=mid)change(p<<1,l,r);
	if(mid+1<=r)change(p<<1|1,l,r);
	t[p]=t[p<<1]+t[p<<1|1];
}
node ask(int p,int l,int r){
	if(l<=t[p].l&&t[p].r<=r){
		return t[p];
	}
	spread(p);
	int mid=(t[p].l+t[p].r)>>1;
	if(r<=mid)return ask(p<<1,l,r);
	if(l>=mid+1)return ask(p<<1|1,l,r);
	return ask(p<<1,l,r)+ask(p<<1|1,l,r);
}
int main(){
    ios::sync_with_stdio(false);
    int n,q;cin>>n>>q;
    string s;cin>>s;
    for(int i=1;i<=n;i++){
    	if(s[i-1]=='<')a[i]=0;
    	else a[i]=1;
    }
    build(1,1,n);
    while(q--){
    	int l,r;
    	cin>>l>>r;
    	//cout<<ask(1,1,n).pr<<endl;
    	change(1,l,r);
    	node c=t[1];
    	//cout<<c.maxrl<<' '<<c.maxlr<<' '<<c.prl<<' '<<c.plr<<' '<<c.srl<<' '<<c.slr<<endl;
    	node ans=ask(1,l,r);
    	cout<<ans.maxrl<<endl;
    }
}