#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*2].rever(),t[2*p+1].rev^=1;
	}
}
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==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;
	}
	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];
    	for(int i=l-1;i<=r-1;i++){
    		if(s[i]=='<')s[i]='>';
    		else s[i]='<';
    	}
    	//cout<<s<<endl;
    	//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=1e5+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();
	}
}
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<<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==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.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(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*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[2*p+1].rev^=1;
	}
}
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].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){
		spread(p);
		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){
		spread(p);
		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;
    }
}


#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){
	spread(p);
	if(l<=t[p].l&&t[p].r<=r){
		return t[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;
	}
	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;
			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(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;
			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;
		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];
    	for(int i=l-1;i<=r-1;i++){
    		if(s[i]=='<')s[i]='>';
    		else s[i]='<';
    	}
    	//cout<<s<<endl;
    	//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;
    }
}


#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){
		spread(p);
		t[p].rever();
		//t[p].rev^=1;
		t[p<<1].rev^=1;
		t[p<<1|1].rev^=1;
		return;
	}
	spread(p);spread(p*2),spread(p*2+1);
	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){
		spread(p);
		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){
		//spread(p);
		t[p].rever();
		//t[p].rev^=1;
		t[p<<1].rev^=1;
		t[p<<1|1].rev^=1;
		return;
	}
	//spread(p);
	spread(p*2),spread(p*2+1);
	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){
		//spread(p);
		return t[p];
	}
	spread(p);
	//spread(p*2),spread(p*2+1);
	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;
			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*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){
		spread(p);
		t[p].rever();
		//t[p].rev^=1;
		t[p<<1].rev^=1;
		t[p<<1|1].rev^=1;
		return;
	}
	spread(p);
	//spread(p*2),spread(p*2+1);
	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){
		spread(p);
		return t[p];
	}
	spread(p);
	spread(p*2),spread(p*2+1);
	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){
	spread(p);
	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){
	spread(p);
	if(l<=t[p].l&&t[p].r<=r){
		return t[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*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){
		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];
    	for(int i=l-1;i<=r-1;i++){
    		if(s[i]=='<')s[i]='>';
    		else s[i]='<';
    	}
    	cout<<s<<endl;
    	//cout<<c.maxrl<<' '<<c.maxlr<<' '<<c.prl<<' '<<c.plr<<' '<<c.srl<<' '<<c.slr<<endl;
    	node ans=ask(1,l,r);
    	cout<<ans.maxrl<<' '<<ans.maxlr<<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*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){
		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];
    	for(int i=l-1;i<=r-1;i++){
    		if(s[i]=='<')s[i]='>';
    		else s[i]='<';
    	}
    	//cout<<s<<endl;
    	//cout<<c.maxrl<<' '<<c.maxlr<<' '<<c.prl<<' '<<c.plr<<' '<<c.srl<<' '<<c.slr<<endl;
    	node ans=ask(1,l,r);
    	cout<<ans.maxrl<<endl;
    	//cout<<ans.maxrl<<' '<<ans.maxlr<<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){
		spread(p);
		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 <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i <= b; i++)
#define per(i, a, b) for (int i = a; i >= b; i--)

using namespace std;

typedef unsigned long long ull;
typedef pair <int, int> pii;
typedef long long ll;

template <typename _T>
inline void read(_T &f) {
    f = 0; _T fu = 1; char c = getchar();
    while (c < '0' || c > '9') { if (c == '-') { fu = -1; } c = getchar(); }
    while (c >= '0' && c <= '9') { f = (f << 3) + (f << 1) + (c & 15); c = getchar(); }
    f *= fu;
}

template <typename T>
void print(T x) {
    if (x < 0) putchar('-'), x = -x;
    if (x < 10) putchar(x + 48);
    else print(x / 10), putchar(x % 10 + 48);
}

template <typename T>
void print(T x, char t) {
    print(x); putchar(t);
}

const int N = 5e5 + 5;

struct info {
	int ans01, ans10, len;
	int lv, lcnt, lans;
	int rv, rcnt, rans;
};

info merge(info a, info b) {
	info ans;
	ans.ans01 = max(a.ans01, b.ans01);
	ans.ans10 = max(a.ans10, b.ans10);
	if (a.rv == 0 && b.lv == 1) ans.ans01 = max(ans.ans01, a.rcnt + b.lcnt);
	if (a.rv == 1 && b.lv == 0) ans.ans10 = max(ans.ans10, a.rcnt + b.lcnt);
	if (a.rv == 0 && b.lv == 0) ans.ans10 = max(ans.ans10, a.rans + b.lcnt), ans.ans01 = max(ans.ans01, a.rcnt + b.lans);
	if (a.rv == 1 && b.lv == 1) ans.ans01 = max(ans.ans01, a.rans + b.lcnt), ans.ans10 = max(ans.ans10, a.rcnt + b.lans);
	ans.len = a.len + b.len;
	ans.lv = a.lv; ans.rv = b.rv;
	if (a.lcnt == a.len) {
		if (a.lv == b.lv) ans.lcnt = a.len + b.lcnt, ans.lans = a.len + b.lans;
		else ans.lcnt = a.lcnt, ans.lans = a.len + b.lcnt;
	} else {
		ans.lcnt = a.lcnt;
		if (a.lans == a.len) {
			if (a.lv == b.lv) ans.lans = a.len;
			else ans.lans = a.len + b.lcnt;
		} else ans.lans = a.lans;
	}
	if (b.rcnt == b.len) {
		if (b.rv == a.rv) ans.rcnt = b.len + a.rcnt, ans.rans = b.len + a.rans;
		else ans.rcnt = b.rcnt, ans.rans = b.len + a.rcnt;
	} else {
		ans.rcnt = b.rcnt;
		if (b.rans == b.len) {
			if (a.rv == b.rv) ans.rans = b.len;
			else ans.rans = b.len + a.rcnt;
		} else ans.rans = b.rans;
	}
	return ans;
}

struct node_t {
	int l, r, rev;
	info val;
} p[N << 2];

char c[N];
int n, q;

void update(int u) { p[u].val = merge(p[u << 1].val, p[u << 1 | 1].val); }

void add_rev(int u) {
	p[u].rev ^= 1;
	swap(p[u].val.ans01, p[u].val.ans10);
	p[u].val.lv ^= 1; p[u].val.rv ^= 1;
}

void pushdown(int u) {
	if (p[u].rev) {
		add_rev(u << 1);
		add_rev(u << 1 | 1);
		p[u].rev = 0;
	}
}

void build(int u, int l, int r) {
	p[u].l = l; p[u].r = r;
	if (l == r) {
		p[u].val.ans01 = p[u].val.ans10 = p[u].val.len = p[u].val.lcnt = p[u].val.lans = p[u].val.rcnt = p[u].val.rans = 1;
		p[u].val.lv = p[u].val.rv = (c[l] == '<');
		return;
	}
	int mid = (l + r) >> 1;
	build(u << 1, l, mid); build(u << 1 | 1, mid + 1, r);
	update(u);
}

info ans; bool ok;
void change(int u, int l, int r) {
	if (l <= p[u].l && p[u].r <= r) {
		add_rev(u);
		if (!ok) ans = p[u].val, ok = 1;
		else ans = merge(ans, p[u].val);
		return;
	}
	pushdown(u);
	int mid = (p[u].l + p[u].r) >> 1;
	if (mid >= l) change(u << 1, l, r);
	if (mid + 1 <= r) change(u << 1 | 1, l, r);
	update(u);
}

int main() {
	read(n); read(q); scanf("%s", c + 1);
	build(1, 1, n);
	for (int i = 1; i <= q; i++) {
		int l, r; read(l); read(r);
		ok = 0;
		change(1, l, r);
		print(ans.ans01, '\n');
	}
	return 0;
}


#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i <= b; i++)
#define per(i, a, b) for (int i = a; i >= b; i--)

using namespace std;

typedef unsigned long long ull;
typedef pair <int, int> pii;
typedef long long ll;

template <typename _T>
inline void read(_T &f) {
    f = 0; _T fu = 1; char c = getchar();
    while (c < '0' || c > '9') { if (c == '-') { fu = -1; } c = getchar(); }
    while (c >= '0' && c <= '9') { f = (f << 3) + (f << 1) + (c & 15); c = getchar(); }
    f *= fu;
}

template <typename T>
void print(T x) {
    if (x < 0) putchar('-'), x = -x;
    if (x < 10) putchar(x + 48);
    else print(x / 10), putchar(x % 10 + 48);
}

template <typename T>
void print(T x, char t) {
    print(x); putchar(t);
}

const int N = 5e5 + 5;

struct info {
	int ans01, ans10, len;
	int lv, lcnt, lans;
	int rv, rcnt, rans;
};

info merge(info a, info b) {
	info ans;
	ans.ans01 = max(a.ans01, b.ans01);
	ans.ans10 = max(a.ans10, b.ans10);
	if (a.rv == 0 && b.lv == 1) ans.ans01 = max(ans.ans01, a.rcnt + b.lcnt);
	if (a.rv == 1 && b.lv == 0) ans.ans10 = max(ans.ans10, a.rcnt + b.lcnt);
	if (a.rv == 0 && b.lv == 0) ans.ans10 = max(ans.ans10, a.rans + b.lcnt), ans.ans01 = max(ans.ans01, a.rcnt + b.lans);
	if (a.rv == 1 && b.lv == 1) ans.ans01 = max(ans.ans10, a.rans + b.lcnt), ans.ans10 = max(ans.ans01, a.rcnt + b.lans);
	ans.len = a.len + b.len;
	ans.lv = a.lv; ans.rv = b.rv;
	if (a.lcnt == a.len) {
		if (a.lv == b.lv) ans.lcnt = a.len + b.lcnt, ans.lans = a.len + b.lans;
		else ans.lcnt = a.lcnt, ans.lans = a.len + b.lcnt;
	} else {
		ans.lcnt = a.lcnt;
		if (a.lans == a.len) {
			if (a.lv == b.lv) ans.lans = a.len;
			else ans.lans = a.len + b.lcnt;
		} else ans.lans = a.lans;
	}
	if (b.rcnt == b.len) {
		if (b.rv == a.rv) ans.rcnt = b.len + a.rcnt, ans.rans = b.len + a.rans;
		else ans.rcnt = b.rcnt, ans.rans = b.len + a.rcnt;
	} else {
		ans.rcnt = b.rcnt;
		if (b.rans == b.len) {
			if (a.rv == b.rv) ans.rans = b.len;
			else ans.rans = b.len + a.rcnt;
		} else ans.rans = b.rans;
	}
	return ans;
}

struct node_t {
	int l, r, rev;
	info val;
} p[N << 2];

char c[N];
int n, q;

void update(int u) { p[u].val = merge(p[u << 1].val, p[u << 1 | 1].val); }

void add_rev(int u) {
	p[u].rev ^= 1;
	swap(p[u].val.ans01, p[u].val.ans10);
	swap(p[u].val.lv, p[u].val.rv); p[u].val.lv ^= 1; p[u].val.rv ^= 1;
	swap(p[u].val.lcnt, p[u].val.rcnt); swap(p[u].val.lans, p[u].val.rans);
}

void pushdown(int u) {
	if (p[u].rev) {
		add_rev(u << 1);
		add_rev(u << 1 | 1);
		p[u].rev = 0;
	}
}

void build(int u, int l, int r) {
	p[u].l = l; p[u].r = r;
	if (l == r) {
		p[u].val.ans01 = p[u].val.ans10 = p[u].val.len = p[u].val.lcnt = p[u].val.lans = p[u].val.rcnt = p[u].val.rans = 1;
		p[u].val.lv = p[u].val.rv = (c[l] == '<');
		return;
	}
	int mid = (l + r) >> 1;
	build(u << 1, l, mid); build(u << 1 | 1, mid + 1, r);
	update(u);
}

info ans; bool ok;
void change(int u, int l, int r) {
	if (l <= p[u].l && p[u].r <= r) {
		add_rev(u);
		if (!ok) ans = p[u].val, ok = 1;
		else ans = merge(ans, p[u].val);
		return;
	}
	pushdown(u);
	int mid = (p[u].l + p[u].r) >> 1;
	if (mid >= l) change(u << 1, l, r);
	if (mid + 1 <= r) change(u << 1 | 1, l, r);
	update(u);
}

int main() {
	read(n); read(q); scanf("%s", c + 1);
	build(1, 1, n);
	for (int i = 1; i <= q; i++) {
		int l, r; read(l); read(r);
		ok = 0;
		change(1, l, r);
		print(ans.ans01, '\n');
	}
	return 0;
}


#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i <= b; i++)
#define per(i, a, b) for (int i = a; i >= b; i--)

using namespace std;

typedef unsigned long long ull;
typedef pair <int, int> pii;
typedef long long ll;

template <typename _T>
inline void read(_T &f) {
    f = 0; _T fu = 1; char c = getchar();
    while (c < '0' || c > '9') { if (c == '-') { fu = -1; } c = getchar(); }
    while (c >= '0' && c <= '9') { f = (f << 3) + (f << 1) + (c & 15); c = getchar(); }
    f *= fu;
}

template <typename T>
void print(T x) {
    if (x < 0) putchar('-'), x = -x;
    if (x < 10) putchar(x + 48);
    else print(x / 10), putchar(x % 10 + 48);
}

template <typename T>
void print(T x, char t) {
    print(x); putchar(t);
}

const int N = 5e5 + 5;

struct info {
	int ans01, ans10, len;
	int lv, lcnt, lans;
	int rv, rcnt, rans;
};

info merge(info a, info b) {
	info ans;
	ans.ans01 = max(a.ans01, b.ans01);
	ans.ans10 = max(a.ans10, b.ans10);
	if (a.rv == 0 && b.lv == 1) ans.ans01 = max(ans.ans01, a.rcnt + b.lcnt);
	if (a.rv == 1 && b.lv == 0) ans.ans10 = max(ans.ans10, a.rcnt + b.lcnt);
	if (a.rv == 0 && b.lv == 0) ans.ans10 = max(ans.ans10, a.rans + b.lcnt), ans.ans01 = max(ans.ans01, a.rcnt + b.lans);
	if (a.rv == 1 && b.lv == 1) ans.ans01 = max(ans.ans10, a.rans + b.lcnt), ans.ans10 = max(ans.ans01, a.rcnt + b.lans);
	ans.len = a.len + b.len;
	ans.lv = a.lv; ans.rv = b.rv;
	if (a.lcnt == a.len) {
		if (a.lv == b.lv) ans.lcnt = a.len + b.lcnt, ans.lans = a.len + b.lans;
		else ans.lcnt = a.lcnt, ans.lans = a.len + b.lcnt;
	} else {
		ans.lcnt = a.lcnt;
		if (a.lans == a.len) {
			if (a.lv == b.lv) ans.lans = a.len;
			else ans.lans = a.len + b.lcnt;
		} else ans.lans = a.lans;
	}
	if (b.rcnt == b.len) {
		if (b.rv == a.rv) ans.rcnt = b.len + a.rcnt, ans.rans = b.len + a.rans;
		else ans.rcnt = b.rcnt, ans.rans = b.len + a.rcnt;
	} else {
		ans.rcnt = b.rcnt;
		if (b.rans == b.len) {
			if (a.rv == b.rv) ans.rans = b.len;
			else ans.rans = b.len + a.rcnt;
		} else ans.rans = b.rans;
	}
	return ans;
}

struct node_t {
	int l, r, rev;
	info val;
} p[N << 2];

char c[N];
int n, q;

void update(int u) { p[u].val = merge(p[u << 1].val, p[u << 1 | 1].val); }

void add_rev(int u) {
	p[u].rev ^= 1;
	swap(p[u].val.ans01, p[u].val.ans10);
	p[u].val.lv ^= 1; p[u].val.rv ^= 1;
}

void pushdown(int u) {
	if (p[u].rev) {
		add_rev(u << 1);
		add_rev(u << 1 | 1);
		p[u].rev = 0;
	}
}

void build(int u, int l, int r) {
	p[u].l = l; p[u].r = r;
	if (l == r) {
		p[u].val.ans01 = p[u].val.ans10 = p[u].val.len = p[u].val.lcnt = p[u].val.lans = p[u].val.rcnt = p[u].val.rans = 1;
		p[u].val.lv = p[u].val.rv = (c[l] == '<');
		return;
	}
	int mid = (l + r) >> 1;
	build(u << 1, l, mid); build(u << 1 | 1, mid + 1, r);
	update(u);
}

info ans; bool ok;
void change(int u, int l, int r) {
	if (l <= p[u].l && p[u].r <= r) {
		add_rev(u);
		if (!ok) ans = p[u].val, ok = 1;
		else ans = merge(ans, p[u].val);
		return;
	}
	pushdown(u);
	int mid = (p[u].l + p[u].r) >> 1;
	if (mid >= l) change(u << 1, l, r);
	if (mid + 1 <= r) change(u << 1 | 1, l, r);
	update(u);
}

int main() {
	read(n); read(q); scanf("%s", c + 1);
	build(1, 1, n);
	for (int i = 1; i <= q; i++) {
		int l, r; read(l); read(r);
		ok = 0;
		change(1, l, r);
		print(ans.ans01, '\n');
	}
	return 0;
}


//#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define trav(x,a) for (const auto& x: a)
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
#define mem(a,v) memset((a), (v), sizeof (a))
#define enl printf("\n")
#define case(t) printf("Case #%d: ", (t))
#define ni(n) scanf("%d", &(n))
#define nl(n) scanf("%I64d", &(n))
#define nai(a, n) for (int _i = 0; _i < (n); _i++) ni(a[_i])
#define nal(a, n) for (int _i = 0; _i < (n); _i++) nl(a[_i])
#define pri(n) printf("%d\n", (n))
#define prl(n) printf("%I64d\n", (n))
#define pii pair<int, int>
#define pll pair<long long, long long>
#define vii vector<pii>
#define vll vector<pll>
#define vi vector<int>
#define vl vector<long long>
#define pb push_back
#define mp make_pair
#define st first
#define nd second
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef cc_hash_table<int,int,hash<int>> ht;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> oset;
const double pi = acos(-1);
const int mod = 1e9 + 7;
const int inf = 1e9 + 7;
const int N = 1e6 + 5;
const double eps = 1e-9;
int a[N];

template<int SZ> struct SEG {
  struct node {
    array<array<int,2>,2> pre, suf;
    int lz, len, m1, m2; // 01, 10
    node() : lz(0) {
      for (int i = 0; i < 2; i++)
        for (int j = 0; j < 2; j++)
          pre[i][j] = suf[i][j] = 0;
    }
    node(int x) : lz(0), m1(0), m2(0), len(1) {
      for (int i = 0; i < 2; i++)
        for (int j = 0; j < 2; j++)
          pre[i][j] = suf[i][j] = 0;
      pre[x][x] = 1;
      suf[x][x] = 1;
    }
  } seg[SZ*4];

  node merge(const node& x, const node& y) {
    node ret = node();
    ret.len = x.len + y.len;
    ret.m1 = max(x.m1, y.m1);
    ret.m2 = max(x.m2, y.m2);
    for (int i = 0; i < 2; i++) {
      for (int j = 0; j < 2; j++) {
        {
          int& val = ret.pre[i][j];
          val = max(0, x.pre[i][j]);
          if (x.pre[i][i] == x.len) {
            if (y.pre[i][j])
              val = max(val, x.pre[i][i] + y.pre[i][j]);
            if (y.pre[j][j])
              val = max(val, x.pre[i][i] + y.pre[j][j]);
          }
          if (x.pre[i][j] == x.len && y.pre[j][j])
            val = max(val, x.pre[i][j] + y.pre[j][j]);
        }
        {
          int& val = ret.suf[i][j];
          val = max(0, y.suf[i][j]);
          if (y.suf[j][j] == y.len) {
            if (x.suf[i][j])
              val = max(val, x.suf[i][j] + y.suf[j][j]);
            if (x.suf[i][i])
              val = max(val, x.suf[i][i] + y.suf[j][j]);
          }
          if (y.suf[i][j] == y.len && x.suf[i][i])
            val = max(val, x.suf[i][i] + y.suf[i][j]);
        }
      }
    }
    if (x.suf[0][1] && y.pre[1][1])
      ret.m1 = max(ret.m1, x.suf[0][1] + y.pre[1][1]);
    if (x.suf[0][0] && y.pre[1][1])
      ret.m1 = max(ret.m1, x.suf[0][0] + y.pre[1][1]);
    if (x.suf[0][0] && y.pre[0][1])
      ret.m1 = max(ret.m1, x.suf[0][0] + y.pre[0][1]);

    if (x.suf[1][0] && y.pre[0][0])
      ret.m2 = max(ret.m2, x.suf[1][0] + y.pre[0][0]);
    if (x.suf[1][1] && y.pre[0][0])
      ret.m2 = max(ret.m2, x.suf[1][1] + y.pre[0][0]);
    if (x.suf[1][1] && y.pre[1][0])
      ret.m2 = max(ret.m2, x.suf[1][1] + y.pre[1][0]);
    return ret;
  }

  void merge(node& x, node& y, node& z) {
    int lz = x.lz;
    x = merge(y, z);
    x.lz = lz;
  }

  void build(int l, int r, int k) {
    if (l == r) {
      seg[k] = node(a[l]);
      return;
    }
    int m = (l+r) / 2;
    build(l,m,k*2);
    build(m+1,r,k*2+1);
    merge(seg[k],seg[k*2],seg[k*2+1]);
  }

  void prop(int l, int r, int k) {
    assert(seg[k].lz == 1);
    if (l != r) {
      seg[k*2].lz ^= seg[k].lz;
      seg[k*2+1].lz ^= seg[k].lz;
    }
    swap(seg[k].pre[0][0], seg[k].pre[1][1]);
    swap(seg[k].pre[0][1], seg[k].pre[1][0]);
    swap(seg[k].suf[0][0], seg[k].suf[1][1]);
    swap(seg[k].suf[0][1], seg[k].suf[1][0]);
    swap(seg[k].m1, seg[k].m2);
    seg[k].lz = 0;
  }

  void upd(int l, int r, int k, int a, int b) {
    if (seg[k].lz) prop(l,r,k);
    if (b < l || r < a) return;
    if (a <= l && r <= b) {
      seg[k].lz ^= 1;
      if (seg[k].lz)
        prop(l,r,k);
      return;
    }
    int m = (l+r) / 2;
    upd(l,m,k*2,a,b);
    upd(m+1,r,k*2+1,a,b);
    merge(seg[k],seg[k*2],seg[k*2+1]);
  }

  node qry(int l, int r, int k, int a, int b) {
    if (seg[k].lz) prop(l,r,k);
    if (a <= l && r <= b) return seg[k];
    int m = (l+r) / 2;
    if (b <= m) return qry(l,m,k*2,a,b);
    if (m < a) return qry(m+1,r,k*2+1,a,b);
    return merge(qry(l,m,k*2,a,b),qry(m+1,r,k*2+1,a,b));
  }
};

SEG<N> seg;

// < -> 0, > -> 1
// .10.
// 0.
// .1
char s[N];

int main() {
  int n, q; scanf("%d %d", &n, &q);
  scanf("%s", s);
  for (int i = 0; i < n; i++)
    a[i] = s[i] == '>';
  seg.build(0, n-1, 1);
  while (q--) {
    int l, r; scanf("%d %d", &l, &r);
    l--, r--;
    seg.upd(0, n-1, 1, l, r);
    SEG<N>::node tmp = seg.qry(0, n-1, 1, l, r);
    int ans = max({tmp.m2, tmp.pre[0][0], tmp.pre[1][1], tmp.suf[1][1], tmp.suf[0][0], tmp.pre[1][0], tmp.suf[1][0]});
    printf("%d\n", ans);
  }
  return 0;
}


/*====Corycle====*/
#include<algorithm>
#include<iostream>
#include<iomanip>
#include<cstring>
#include<cstdlib>
#include<complex>
#include<cstdio>
#include<vector>
#include<cmath>
#include<ctime>
#include<stack>
#include<queue>
#include<map>
#define ll long long
#define lson p<<1,l,mid
#define rson p<<1|1,mid+1,r
using namespace std;
const int inf=0x3f3f3f3f;
const int N=5e5+5;
int read(){
	int s=0,f=1;char c=getchar();
	while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
	while(c>='0'&&c<='9'){s=s*10+c-'0';c=getchar();}
	return s*f;
}
char s[N];
int n,m,Flag;
struct Node{
	int num,ans,l1,r0,lans,rans;
	void Clear(){num=ans=l1=r0=lans=rans=0;}
	void Init(int c){num=ans=lans=rans=1;c?l1=1:r0=1;}
	friend Node operator+(Node A,Node B){
		Node C;C.Clear();
		C.num=A.num+B.num;
		C.l1=(A.l1==A.num?A.num+B.l1:A.l1);
		C.r0=(B.r0==B.num?B.num+A.r0:B.r0);
		C.lans=max((A.lans==A.num?A.lans+B.l1:A.lans),(A.r0==A.num?A.num+B.lans:0));
		C.rans=max((B.rans==B.num?B.rans+A.r0:B.rans),(B.l1==B.num?B.num+A.rans:0));
		C.ans=max(max(C.lans,C.rans),max(max(A.ans,B.ans),max(A.rans+B.l1,A.r0+B.lans)));
		return C;
	}
};
Node Answer;
struct Tree{
	int tag;Node A,B;
	void Init(int c){tag=0;A.Init(c);B.Init(c^1);}
};
struct Segment_Tree{
	Tree t[N*4];
	void update(int p){t[p].tag^=1;swap(t[p].A,t[p].B);}
	void Pushdown(int p){if(t[p].tag){update(p<<1);update(p<<1|1);t[p].tag=0;}}
	void Pushup(int p){t[p].A=t[p<<1].A+t[p<<1|1].A;t[p].B=t[p<<1].B+t[p<<1|1].B;}
	void Build(int p,int l,int r){
		if(l==r){t[p].Init(s[l]=='>'?0:1);return;}
		int mid=(l+r)>>1;Build(lson);Build(rson);Pushup(p);
	}
	void Update(int x,int y,int p,int l,int r){
		if(y<l||x>r)return;
		if(x<=l&&r<=y){update(p);return;}
		int mid=(l+r)>>1;Pushdown(p);
		Update(x,y,lson);Update(x,y,rson);Pushup(p);
	}
	void Query(int x,int y,int p,int l,int r){
		if(y<l||x>r)return;
		if(x<=l&&r<=y){Answer=Flag?Answer+t[p].A:t[p].A;Flag=1;return;}
		int mid=(l+r)>>1;Pushdown(p);
		Query(x,y,lson);Query(x,y,rson);
	}
}tree;
int main(){
//	freopen("_.in","r",stdin);
//	freopen("_.out","w",stdout);
	n=read();m=read();scanf("%s",s+1);
	tree.Build(1,1,n);
	while(m--){
		Answer.Clear();Flag=0;
		int l=read(),r=read();
		tree.Update(l,r,1,1,n);
		tree.Query(l,r,1,1,n);
		printf("%d\n",Answer.ans);
	}
	return 0;
}


#include<bits/stdc++.h>
#define LL long long
#define pb push_back
#define SZ(x) ((int)x.size()-1)
#define ms(a,b) memset(a,b,sizeof a)
#define F(i,a,b) for (int i=(a);i<=(b);++i)
#define DF(i,a,b) for (int i=(a);i>=(b);--i)
using namespace std;
inline int read(){
	char ch=getchar(); int w=1,c=0;
	for(;!isdigit(ch);ch=getchar()) if (ch=='-') w=-1;
	for(;isdigit(ch);ch=getchar()) c=(c<<1)+(c<<3)+(ch^48);
	return w*c;
}
const int M=5e5+10;
int n,q,b[M];
char ch[M];
struct node{
	int l0,r1,al,ar,s,len;
	node (){
		l0=r1=al=ar=s=len=0;
	}
}a[M<<3],c[M<<3];
#define lc (x<<1)
#define rc (x<<1|1)
#define mid (l+r>>1)
bool tg[M<<3];
node pu(node A,node B,bool out){
	node C;
	C.s=max(A.s,max(B.s,max(A.r1+B.l0,max(A.ar+B.l0,max(A.al,max(B.al+A.r1,B.ar))))));
	C.l0=(A.len==A.l0 ? A.l0+B.l0 : A.l0);
	C.r1=(B.len==B.r1 ? B.r1+A.r1 : B.r1);
	C.al=(A.len==A.r1 ? A.r1+max(B.al,B.l0) : (A.len==A.al ? A.len+B.l0 : A.al));
//	if (out) cout<<A.al<<" "<<C.al<<" "<<C.s<<"  pu\n";
	C.ar=(B.len==B.l0 ? B.l0+max(A.ar,A.r1) : (B.len==B.ar ? B.len+A.r1 : B.ar));
	C.len=A.len+B.len;
	return C;
}
int tot;
void build(int x,int l,int r){
	c[x].len=a[x].len=r-l+1;
	if (l==r){
		if (b[l]) a[x].al=a[x].r1=a[x].s=1,c[x].ar=c[x].l0=c[x].s=1;
		else a[x].ar=a[x].l0=a[x].s=1,c[x].al=c[x].r1=c[x].s=1;
		return ;
	}
	build(lc,l,mid); build(rc,mid+1,r);
	a[x]=pu(a[lc],a[rc],0);
	c[x]=pu(c[lc],c[rc],0);
}
void rev(int x){
	tg[x]^=1;
	swap(a[x],c[x]);
}
void pd(int x){
	if (tg[x]){
		rev(lc); rev(rc);
		tg[x]=0;
	}
}
void upd(int x,int l,int r,int ll,int rr){
	if (l==ll && r==rr){
		rev(x);
		return ;
	}
	pd(x);
	if (rr<=mid)upd(lc,l,mid,ll,rr);
	else if (ll>mid) upd(rc,mid+1,r,ll,rr);
	else upd(lc,l,mid,ll,mid),upd(rc,mid+1,r,mid+1,rr);
//	cout<<"A "<<l<<" "<<r<<"   ggsdg\n";
	a[x]=pu(a[lc],a[rc],0);
	c[x]=pu(c[lc],c[rc],0);
}
node qry(int x,int l,int r,int ll,int rr){
//	cout<<x<<" "<<l<<" "<<r<<" ipipi "<<"\n";
	if (l==ll && r==rr){
		return a[x];
	}
	pd(x);
	if (rr<=mid)return qry(lc,l,mid,ll,rr);
	if (ll>mid) return qry(rc,mid+1,r,ll,rr);
	node TA=qry(lc,l,mid,ll,mid),TB=qry(rc,mid+1,r,mid+1,rr);
//	cout<<TA.s<<" "<<TB.s<<" "<<l<<" "<<r<<"   hhh\n";
	return pu(TA,TB,0);
}
int rt;
int main(){
	n=read(); q=read();
	scanf("%s",ch+1);
	F(i,1,n) b[i]=(ch[i]=='<' ? 0 : 1);
	build(1,1,n);
//	cout<<a[rt].s<<"  ggsb\n";
	while (q--){
		int x=read(),y=read();
		upd(1,1,n,x,y);
		node tmp=qry(1,1,n,x,y);
		cout<<max(tmp.s,max(tmp.l0,tmp.r1))<<"\n";
//		F(i,1,n) cout<<qry(1,1,n,i,i).r1; cout<<"\n";
	}
	return 0;
}


#include<bits/stdc++.h>
#define pb push_back
using namespace std;

const int N=5e5+10,M=N<<2;
int n,Q;
char s[N];

int read()
{
	int ret=0;char c=getchar();
	while(!isdigit(c)) c=getchar();
	while(isdigit(c)) ret=ret*10+(c^48),c=getchar();
	return ret;
}

namespace Segment
{
	struct Node
	{
		int l,r,lp,rp,llen,rlen,ans,len;
		friend Node operator + (Node a,Node b)
		{
			Node ret;int m=a.r;ret.l=a.l;ret.r=b.r;
			if(a.llen==a.len && a.lp>=m && b.lp<=m) ret.lp=m,ret.llen=a.len+b.llen;
			else if(a.llen==a.len && a.lp>=m && b.lp>m) ret.lp=b.lp,ret.llen=a.len+b.llen;
			else if(a.llen==a.len && a.lp<m && b.lp<=m) ret.lp=a.lp,ret.llen=a.len+b.llen;
			else ret.lp=a.lp,ret.llen=a.llen;

			if(b.rlen==b.len && a.rp>=m && b.rp<=m) ret.rp=m,ret.rlen=b.len+a.rlen;
			else if(b.rlen==b.len && a.rp>=m && b.rp>m) ret.rp=b.rp,ret.rlen=b.len+a.rlen;
			else if(b.rlen==b.len && a.rp<m && b.rp<=m) ret.rp=a.rp,ret.rlen=b.len+a.rlen;
			else ret.rp=b.rp,ret.rlen=b.rlen;

			ret.ans=max(a.ans,b.ans);
			if(a.rp>=m || b.lp<=m) ret.ans=max(ret.ans,a.rlen+b.llen);
			return ret;
		}
	};

	struct Segment
	{
		#define ls (x<<1)
		#define rs (x<<1|1)
		#define y (x+M)
		Node t[M<<1];int tar[M];

		void pushup(int x)
		{
			t[x]=t[ls]+t[rs];
			t[y]=t[ls+M]+t[rs+M];
		}
		void rev(int x)
		{
			tar[x]^=1;
			swap(t[x].llen,t[y].llen);swap(t[x].rlen,t[y].rlen);
			swap(t[x].lp,t[y].lp);swap(t[x].rp,t[y].rp);
			swap(t[x].ans,t[y].ans);
		}
		void pushdown(int x)
		{
			if(tar[x]) tar[x]=0,rev(ls),rev(rs);
		}
		void build(int x,int l,int r)
		{
			t[x].l=t[y].l=l;t[x].r=t[y].r=r;t[x].len=t[y].len=r-l+1;
			if(l==r)
			{
				t[x].ans=t[x].llen=t[x].rlen=t[y].ans=t[y].llen=t[y].rlen=1;
				if(s[l]=='<') t[x].lp=t[x].rp=l-1,t[y].lp=t[y].rp=l;
				else t[x].lp=t[x].rp=l,t[y].lp=t[y].rp=l-1;
				return;
			}
			int mid=(l+r)>>1;
			build(ls,l,mid);build(rs,mid+1,r);
			pushup(x);
		}
		void update(int x,int l,int r,int L,int R)
		{
			if(L<=l && r<=R) {rev(x);return;}
			pushdown(x);
			int mid=(l+r)>>1;
			if(L<=mid) update(ls,l,mid,L,R);
			if(R>mid) update(rs,mid+1,r,L,R);
			pushup(x);
		}
		Node query(int x,int l,int r,int L,int R)
		{
			if(L==l && r==R) return (Node){l,r,t[x].lp,t[x].rp,t[x].llen,t[x].rlen,t[x].ans,t[x].len};
			pushdown(x);
			int mid=(l+r)>>1;
			if(R<=mid) return query(ls,l,mid,L,R);
			if(L>mid) return query(rs,mid+1,r,L,R);
			return query(ls,l,mid,L,mid)+query(rs,mid+1,r,mid+1,R);
 		}
		#undef ls
		#undef rs
	}T;
}
using namespace Segment;

int main()
{
#ifdef Durant_Lee
	freopen("a.in","r",stdin);
	freopen("a.out","w",stdout);
#endif
	n=read();Q=read();scanf("%s",s+1);
	T.build(1,1,n);
	while(Q--)
	{
		int l=read(),r=read();
		T.update(1,1,n,l,r);
		printf("%d\n",T.query(1,1,n,l,r).ans);
	}
	return 0;
}


//W4P3R
#include<bits/stdc++.h>
#define inf 1e9
#define eps 1e-6
#define mp make_pair
#define pb push_back
#define re register int
#define fr first
#define sd second
#define pa pair<int,int>
#define FOR(i,a,b) for(re i=a;i<=b;i++)
#define REP(i,a,b) for(re i=a;i>=b;i--)
#define lowbit(x) (x&(-x))
#define Z(x) (x>=mod?x-mod:x)
#define N 500010
#define mid ((l+r)>>1)
#define ls (x<<1)
#define rs (x<<1|1)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
inline ll read()
{
	char ch=getchar();
	ll s=0,w=1;
	while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){s=s*10+ch-'0';ch=getchar();}
	return s*w;
}
struct node
{
	int lt,rt,lval,rval;
	int maxn;
}t[N<<2][2];int tag[N<<2];
int n,q;char s[N];
inline void push(node &a,int t){a.maxn=a.lval=a.rval=1;a.lt=a.rt=t;}
inline void pushtag(int x){swap(t[x][0],t[x][1]);tag[x]^=1;}
inline void pushdown(int x){if(tag[x]){pushtag(ls);pushtag(rs);tag[x]=0;}}
inline node pushup(node a,node b,int L1,int L2)
{
	node c;c.maxn=max(a.maxn,b.maxn);
	c.lt=a.lt;c.rt=b.rt;c.lval=a.lval;c.rval=b.rval;
	if(a.rt!=1||b.lt!=0){c.maxn=max(c.maxn,a.rval+b.lval);if(a.rval==L1)c.lval=L1+b.lval;if(b.lval==L2)c.rval=L2+a.rval;}
	return c;
}
void build(int l,int r,int x)
{
	if(l==r){push(t[x][0],0);push(t[x][1],1);if(s[l]=='<')swap(t[x][0],t[x][1]);return ;}
	build(l,mid,ls);build(mid+1,r,rs);
	t[x][0]=pushup(t[ls][0],t[rs][0],mid-l+1,r-mid);
	t[x][1]=pushup(t[ls][1],t[rs][1],mid-l+1,r-mid);
}
void update(int l,int r,int x,int left,int right)
{
	if(l==left&&right==r){pushtag(x);return ;}
	pushdown(x);
	if(right<=mid)update(l,mid,ls,left,right);
	else if(left>mid)update(mid+1,r,rs,left,right);
	else update(l,mid,ls,left,mid),update(mid+1,r,rs,mid+1,right);
	t[x][0]=pushup(t[ls][0],t[rs][0],mid-l+1,r-mid);
	t[x][1]=pushup(t[ls][1],t[rs][1],mid-l+1,r-mid);
}
node query(int l,int r,int x,int left,int right)
{
	if(l==left&&right==r){return t[x][0];}
	pushdown(x);
	if(right<=mid)return query(l,mid,ls,left,right);
	else if(left>mid)return query(mid+1,r,rs,left,right);
	else return pushup(query(l,mid,ls,left,mid),query(mid+1,r,rs,mid+1,right),mid-left+1,right-mid);
}
int main()
{
	//ios::sync_with_stdio(false);
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	n=read(),q=read();
	scanf("%s",s+1);
	build(1,n,1);
	while(q--)
	{
		int l=read(),r=read();
		update(1,n,1,l,r);
		node ans=query(1,n,1,l,r);
		printf("%d\n",ans.maxn);
	}
	return 0;
}
//check first submit second


//W4P3R
#include<bits/stdc++.h>
#define inf 1e9
#define eps 1e-6
#define mp make_pair
#define pb push_back
#define re register int
#define fr first
#define sd second
#define pa pair<int,int>
#define FOR(i,a,b) for(re i=a;i<=b;i++)
#define REP(i,a,b) for(re i=a;i>=b;i--)
#define lowbit(x) (x&(-x))
#define Z(x) (x>=mod?x-mod:x)
#define N 500010
#define mid ((l+r)>>1)
#define ls (x<<1)
#define rs (x<<1|1)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
inline ll read()
{
	char ch=getchar();
	ll s=0,w=1;
	while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){s=s*10+ch-'0';ch=getchar();}
	return s*w;
}
struct node
{
	int lv,lt,rv,rt,lval,rval;
	int maxn;
}t[N<<2][2];int tag[N<<2];
int n,q;char s[N];
inline void push(node &a,int t){a.lv=a.rv=a.maxn=1;a.lt=a.rt=t;a.lval=a.rval=1;}
inline void pushtag(int x){swap(t[x][0],t[x][1]);tag[x]^=1;}
inline void pushdown(int x){if(tag[x]){pushtag(ls);pushtag(rs);tag[x]=0;}}
inline node pushup(node a,node b,int L1,int L2)
{
	node c;c.maxn=max(a.maxn,b.maxn);
	c.lv=a.lv;c.lt=a.lt;c.rv=b.rv;c.rt=b.rt;
	c.lval=a.lval;c.rval=b.rval;
	if(a.rt==0&&b.lt==0){c.maxn=max(c.maxn,a.rv+b.lval);if(a.rv==L1)c.lv=L1+b.lv,c.lval=L1+b.lval;if(b.lv==L2)c.rv=L2+a.rv,c.rval=L2+a.rv;}
	if(a.rt==0&&b.lt==1){c.maxn=max(c.maxn,a.rv+b.lv);if(a.rv==L1)c.lval=L1+b.lv;if(b.lv==L2)c.rval=L2+a.rv;}
	if(a.rt==1&&b.lt==0);
	if(a.rt==1&&b.lt==1){c.maxn=max(c.maxn,a.rval+b.lv);if(a.rv==L1)c.lv=L1+b.lv,c.lval=L1+b.lval;if(b.lv==L2)c.rv=L2+a.rv,c.rval=L2+a.rv;}
	return c;
}
void build(int l,int r,int x)
{
	if(l==r){push(t[x][0],0);push(t[x][1],1);if(s[l]=='<')swap(t[x][0],t[x][1]);return ;}
	build(l,mid,ls);build(mid+1,r,rs);
	t[x][0]=pushup(t[ls][0],t[rs][0],mid-l+1,r-mid);
	t[x][1]=pushup(t[ls][1],t[rs][1],mid-l+1,r-mid);
}
void update(int l,int r,int x,int left,int right)
{
	if(l==left&&right==r){pushtag(x);return ;}
	pushdown(x);
	if(right<=mid)update(l,mid,ls,left,right);
	else if(left>mid)update(mid+1,r,rs,left,right);
	else update(l,mid,ls,left,mid),update(mid+1,r,rs,mid+1,right);
	t[x][0]=pushup(t[ls][0],t[rs][0],mid-l+1,r-mid);
	t[x][1]=pushup(t[ls][1],t[rs][1],mid-l+1,r-mid);
}
node query(int l,int r,int x,int left,int right)
{
	if(l==left&&right==r){return t[x][0];}
	pushdown(x);
	if(right<=mid)return query(l,mid,ls,left,right);
	else if(left>mid)return query(mid+1,r,rs,left,right);
	else return pushup(query(l,mid,ls,left,mid),query(mid+1,r,rs,mid+1,right),mid-left+1,right-mid);
}
int main()
{
	//ios::sync_with_stdio(false);
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	n=read(),q=read();
	scanf("%s",s+1);
	build(1,n,1);
	while(q--)
	{
		int l=read(),r=read();
		update(1,n,1,l,r);
		node ans=query(1,n,1,l,r);
		printf("%d\n",ans.maxn);
	}
	return 0;
}
//check first submit second