Problem: Ikta, who was in trouble because he couldn't come up with an idea for the problem to be presented at the training camp of the programming contest, consulted with a friend one day.

Mr. Ikta "I want to create a problem that cannot be solved without using such an algorithm. Is there anything?"

Friend "Then why not think about something like this?"

In this way, the friend came up with the idea that would be the basis for the following problems.

Given binary numbers A and B, process the following query.

* Output query: Outputs the number of 1s when max {x is expressed in binary | A ≤ x <A + B}
* A change query: Inverts the i-th bit (0-origin) from the least significant bit of A
* B change query: Inverts the i-th bit (0-origin) from the least significant bit of B



Note that the i-bit is represented by 0-origin. That is, the 0th bit from the least significant bit of A represents the least significant bit.



Input

The input is given in the following format.


N A B
Q1
...
QN

The number of queries N, binary numbers A and B are given in the first line.

The following query is given in the 2nd to N + 1 lines.

* Q
* A i
* B i



Q represents the output query, and A i and B i represent the change query that inverts the i-th bit from the least significant bit of A and the i-th bit from the least significant bit of B, respectively.

Constraints

Each variable being input satisfies the following constraints.

* 1 ≤ N <300,000
* 1 ≤ | A |, | B | ≤ 300,000 (| A | is the length of A)
* In the query A i, 0 ≤ i <| A |
* In the query B i 0 ≤ i <| B |
* B can never be 0

Output

Print the answer on one line for each output query.

Examples

Input

4 10000 00101
Q
A 0
B 1
Q


Output

3
4


Input

9 0110111101 0010100111
Q
B 4
Q
A 4
Q
B 9
Q
A 8
Q


Output

9
9
9
10
9

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
const int N=300000,p2=1<<19;
int A[N],B[N];
int bit[N+1];
bool seg[p2*2];
set<int> bs,twos;
int sum(int i){
	int s=0;
	while(i>0){
		s+=bit[i];
		i=(i&(i-1));
	}
	return s;
}
void add(int i,int x){
	while(i<=N){
		bit[i]+=x;
		i+=(i&-i);
	}
}
void update(int x){
	seg[x+p2]=(A[x]+B[x]>=1);
	x+=p2;
	while(true){
		x/=2;
		if(x==0) break;
		seg[x]=seg[x*2]&&seg[x*2+1];
	}
}
bool q(int a,int b,int l,int r,int k){
	if(b<=l||r<=a) return 1;
	if(a<=l&&r<=b) return seg[k];
	return q(a,b,l,(l+r)/2,k*2)&&q(a,b,(l+r)/2,r,k*2+1);
}
int main(){
	int Q;
	string As,Bs;
	cin>>Q>>As>>Bs;
	rep(i,As.size()) A[N-1-i]=As[As.size()-1-i]-'0';
	rep(i,Bs.size()) B[N-1-i]=Bs[Bs.size()-1-i]-'0';
	rep(i,N){
		if(B[i]) bs.insert(i);
		if(A[i]+B[i]==2) twos.insert(i);
		add(i+1,A[i]);
		update(i);
	}
	rep(tt,Q){
		char c;
		cin>>c;
		if(c=='Q'){
			int b=*bs.begin();
			int ans=sum(b)+N-1-b;
			if(!twos.empty()){
				int t=*twos.begin();
				if(q(b,t+1,0,p2,1)) ans++;
			}
			cout<<ans<<endl;
		}else if(c=='A'){
			int x;
			cin>>x;
			x=N-1-x;
			int d=1;
			if(A[x]==1) d=-1;
			A[x]+=d;
			add(x+1,d);
			twos.erase(x);
			if(A[x]+B[x]==2) twos.insert(x);
			update(x);
		}else{
			int x;
			cin>>x;
			x=N-1-x;
			int d=1;
			if(B[x]==1) d=-1;
			B[x]+=d;
			bs.erase(x);
			if(B[x]) bs.insert(x);
			twos.erase(x);
			if(A[x]+B[x]==2) twos.insert(x);
			update(x);
		}
	}
}