p01727 A + B_13779
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
#include<stdio.h>
#include<algorithm>
#include<string.h>
#include<set>
using namespace std;
char A[310000];
char B[310000];
int p[310000];
int q[310000];
int bit[310000];
set<int>zero;
set<int>two;
set<int>bb;
int sum(int a,int b){
	if(a)return sum(0,b)-sum(0,a-1);
	int ret=0;
	for(;b>=0;b=(b&(b+1))-1)ret+=bit[b];
	return ret;
}
void add(int a,int b){
	for(;a<310000;a|=a+1)bit[a]+=b;
}
char in[2];
int main(){
	int a;
	scanf("%d",&a);
	scanf("%s%s",A,B);
	int as=strlen(A);
	int bs=strlen(B);
	two.insert(-1);
	zero.insert(-1);
	for(int i=0;i<as;i++){
		p[i]=A[as-1-i]-'0';
	}
	for(int i=0;i<bs;i++){
		q[i]=B[bs-1-i]-'0';
	}
	int sz=max(as,bs)+1;
	for(int i=0;i<sz;i++){
		if(p[i]+q[i]==2)two.insert(i);
		if(p[i]+q[i]==0)zero.insert(i);
		if(q[i])bb.insert(i);
		if(p[i])add(i,1);
	}
	for(int i=0;i<a;i++){
		scanf("%s",in);
		if(in[0]=='Q'){
			int at=*(bb.rbegin());
			int val=sum(at,sz);
			int ret=val+at;
			if(p[at]==0){
				int nt=*(--(two.lower_bound(at)));
				int nz=*(--(zero.lower_bound(at)));
		//		printf("%d %d\n",nt,nz);
				if(nt>nz){
					ret++;
				}
			}
			printf("%d\n",ret);
		}else if(in[0]=='A'){
			int t;scanf("%d",&t);
			if(p[t]==0){
				if(q[t]+p[t]==0)zero.erase(t);
				p[t]=1;
				if(q[t]+p[t]==2)two.insert(t);
				add(t,1);
			}else{
				if(q[t]+p[t]==2)two.erase(t);
				p[t]=0;
				if(q[t]+p[t]==0)zero.insert(t);
				add(t,-1);
			}
		}else{
			int t;scanf("%d",&t);
			if(q[t]==0){
				if(q[t]+p[t]==0)zero.erase(t);
				q[t]=1;
				if(q[t]+p[t]==2)two.insert(t);
				bb.insert(t);
			}else{
				if(q[t]+p[t]==2)two.erase(t);
				q[t]=0;
				if(q[t]+p[t]==0)zero.insert(t);
				bb.erase(t);
			}
		}
	}
}