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>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

signed main(){  
  cin.tie(0);
  ios::sync_with_stdio(0);
  Int n;
  string a,b;
  cin>>n>>a>>b;
  if(a.size()<b.size()) a=string(b.size()-a.size(),'0')+a;
  if(a.size()>b.size()) b=string(a.size()-b.size(),'0')+b;

  const Int l=a.size();

  
  const Int BS = 600;
  vector<Int> cnt(l/BS+1,0),sft(l/BS+1,0);
  auto calc=[&](Int x){
    Int y=x*BS;
    cnt[x]=0;
    sft[x]=-l*2;
    for(Int i=0;i<BS;i++){
      if(y+i>=l) break;
      if(b[y+i]=='1') chmax(sft[x],cnt[x]+(a[y+i]=='1')+l-(y+i+1));
      cnt[x]+=a[y+i]=='1'||b[y+i]=='1';
    }
    //cout<<x<<":"<<cnt[x]<<" "<<sft[x]<<endl;
  };
  
  for(Int i=0;i<l;i+=BS) calc(i/BS);
  
  Int ans=0;
  auto recalc=[&](){
    ans=0;
    Int tmp=0;
    for(Int i=0;i<l;i+=BS){
      Int x=i/BS;
      chmax(ans,tmp+sft[x]);
      tmp+=cnt[x];
    }
  };
  
  for(Int i=0;i<n;i++){
    char c;
    cin>>c;
    if(c=='Q'){
      recalc();
      cout<<ans<<endl;
      continue;
    }
    Int p;
    cin>>p;
    p++;
    if(c=='A') a[l-p]=!(a[l-p]-'0')+'0';
    if(c=='B') b[l-p]=!(b[l-p]-'0')+'0';

    calc((l-p)/BS);
  }
  
  return 0;
}