#include <bits/stdc++.h>

#define ll          long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)
using namespace std;
int lz(string s){
    int mx=1;
    int i=0;
    int l=s.length();
    int a[l];
    while(i<l-1){
        int temp=1;
        while(i<l-1&&s[i]!=s[i+1]){
            temp++;
            i++;
            //cout<<s[i]<<" "<<temp<<" ";
        }
        //cout<<endl;
        mx=max(mx,temp);
        i++;
    }
    return mx;
}
void solve(){
   string s;
   cin>>s;
   int l=s.length();

   if(s[l-1]==s[0]){
        cout<<lz(s);
        return;
    }
    int i=0;
    int k=l;
    while(i<l-1&&s[i]!=s[i+1])i++;
    while(k>0&&s[k]!=s[k-1])k--;

    if(i==l-1){
        cout<<lz(s);
        return;
    }
    cout<<i+1+(l-1-k)+1;
    return;
}
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int t=1;
    //cin>>t;
	while(t--){
		solve();
	}
	return 0;
}


#include <bits/stdc++.h>
#include <math.h>
#define ll long long
using namespace std;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    string s;
    cin>>s;
    ll n= s.length();
    ll l1=0,l=0,l2=0,temp=0;
    for(ll i=0; i<n-1; i++)
    {
    	l1++;
    	if(s[i]==s[i+1])
    	{
    		break;
    	}
    }
    for(ll i=0; i<n-1; i++)
    {
    	temp++;
    	if(s[i]==s[i+1])
    	{
    		if(temp>l)
    			l=temp;
    		temp=0;
    	}
    }
    for(ll i=n-1; i>=0; i--)
    {
    	l2++;
    	if(s[i]==s[i-1])
    		break;
    }
    if(l1 + l2 > n)
    {
    	cout<<l;
    	return 0;
    }
    else if(l1 + l2 > l && s[0]!=s[n-1])
    {
    	cout<< l1 + l2;
    	return 0;
    }

    else
    {
    	cout<<l;
    	return 0;
    }
    return 0;
}


#include <bits/stdc++.h>
#include <math.h>
#define ll long long
using namespace std;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    string s;
    cin>>s;
    ll n= s.length();
    ll l1=0,l=0,l2=0,temp=0;
    for(ll i=0; i<n-1; i++)
    {
    	l1++;
    	if(s[i]==s[i+1])
    	{
    		break;
    	}
    }
    for(ll i=0; i<n-1; i++)
    {
    	temp++;
    	if(s[i]==s[i+1])
    	{
    		if(temp>l)
    			l=temp;
    		temp=0;
    	}
    }
    for(ll i=n-1; i>=0; i--)
    {
    	l2++;
    	if(s[i]==s[i-1])
    		break;
    }
    if(s[0]==s[n-1])
    {
    	l1--;
    }
    if(l1 + l2 > n)
    {
    	cout<<l;
    	return 0;
    }
    else if(l1 + l2 > l)
    {
    	cout<< l1 + l2;
    	return 0;
    }

    else
    {
    	cout<<l;
    	return 0;
    }
    return 0;
}


#include <bits/stdc++.h>
#include <math.h>
#define ll long long
using namespace std;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    string s;
    cin>>s;
    ll n= s.length();
    ll l1=0,l=0,l2=0,temp=0;
    for(ll i=0; i<n-1; i++)
    {
    	l1++;
    	if(s[i]==s[i+1])
    	{
    		break;
    	}
    }
    for(ll i=0; i<n-1; i++)
    {
    	temp++;
    	if(s[i]==s[i+1])
    	{
    		if(temp>l)
    			l=temp;
    		temp=0;
    	}
    }
    for(ll i=n-1; i>=0; i--)
    {
    	l2++;
    	if(s[i]==s[i-1])
    		break;
    }
    if(n==1)
    {
    	cout<<"1";
    	return 0;
    }
    else if(l==n)
    {
    	cout<<l;
    	return 0;
    }
    else if(l1 + l2 > l && s[0]!=s[n-1])
    {
    	cout<< l1 + l2;
    	return 0;
    }

    else
    {
    	cout<<l;
    	return 0;
    }
    return 0;
}


#include <bits/stdc++.h>
#include <math.h>
#define ll long long
using namespace std;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    string s;
    cin>>s;
    ll n= s.length();
    ll l1=0,l=0,l2=0,temp=0;
    for(ll i=0; i<n-1; i++)
    {
    	l1++;
    	if(s[i]==s[i+1])
    	{
    		break;
    	}
    	if(i==n-2)
    	{
    		if(s[i]!=s[i+1])
    			l1++;
    	}
    }
    for(ll i=0; i<n-1; i++)
    {
    	temp++;
    	if(s[i]==s[i+1])
    	{
    		if(temp>l)
    			l=temp;
    		temp=0;
    	}
    	if(i==n-2)
    	{
    		if(s[i]!=s[i+1])
    			temp++;
    		if(temp>l)
    			l=temp;
    	}
    }
    for(ll i=n-1; i>=0; i--)
    {
    	l2++;
    	if(s[i]==s[i-1])
    		break;
    }
    if(n==1)
    {
    	cout<<"1";
    	return 0;
    }
    else if(l==n)
    {
    	cout<<l;
    	return 0;
    }
    else if(l1 + l2 > l && s[0]!=s[n-1])
    {
    	cout<< l1 + l2;
    	return 0;
    }

    else
    {
    	cout<<l;
    	return 0;
    }
    return 0;
}


#include <bits/stdc++.h>
#include <math.h>
#define ll long long
using namespace std;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    string s;
    cin>>s;
    ll n= s.length();
    ll l1=0,l=0,l2=0,temp=0;
    for(ll i=0; i<n-1; i++)
    {
    	l1++;
    	if(s[i]==s[i+1])
    	{
    		break;
    	}
    }
    for(ll i=0; i<n-1; i++)
    {
    	temp++;
    	if(s[i]==s[i+1])
    	{
    		if(temp>l)
    			l=temp;
    		temp=0;
    	}
    }
    for(ll i=n-1; i>=0; i--)
    {
    	l2++;
    	if(s[i]==s[i-1])
    		break;
    }
    if(l==n)
    {
    	cout<<l;
    	return 0;
    }
    else if(l1 + l2 > l && s[0]!=s[n-1])
    {
    	cout<< l1 + l2;
    	return 0;
    }

    else
    {
    	cout<<l;
    	return 0;
    }
    return 0;
}


#include <algorithm>
#include <iostream>
#include <cstring>
#include <climits>
#include <cstdio>
#define DEBUG(x) std::cerr << #x << '=' << x << std::endl

namespace fastIO{
#define BUF_SIZE 100000
#define OUT_SIZE 100000
#define ll long long
    bool IOerror=0;
    inline char nc(){
        static char buf[BUF_SIZE],*p1=buf+BUF_SIZE,*pend=buf+BUF_SIZE;
        if (p1==pend){
            p1=buf; pend=buf+fread(buf,1,BUF_SIZE,stdin);
            if (pend==p1){IOerror=1;return -1;}
        }
        return *p1++;
    }
    inline bool blank(char ch){return ch==' '||ch=='\n'||ch=='\r'||ch=='\t';}
    inline void read(int &x){
        bool sign=0; char ch=nc(); x=0;
        for (;blank(ch);ch=nc());
        if (IOerror)return;
        if (ch=='-')sign=1,ch=nc();
        for (;ch>='0'&&ch<='9';ch=nc())x=x*10+ch-'0';
        if (sign)x=-x;
    }
    inline void read(ll &x){
        bool sign=0; char ch=nc(); x=0;
        for (;blank(ch);ch=nc());
        if (IOerror)return;
        if (ch=='-')sign=1,ch=nc();
        for (;ch>='0'&&ch<='9';ch=nc())x=x*10+ch-'0';
        if (sign)x=-x;
    }
#undef ll
#undef OUT_SIZE
#undef BUF_SIZE
};
using namespace fastIO;
#define DEBUG(x) std::cerr << #x << '=' << x << std::endl

const int MAXN = 100000 + 5;
int f[MAXN*3];

int main(){
    std::string str;
    std::cin >> str;
    int len = (unsigned)str.length();
    f[0] = 1;
    for(int i = 1;i < len;i++){
        if(str[i] != str[i-1]) f[i] = f[i-1]+1;
        else f[i] = 1;
    }
    // DEBUG(str[0]);DEBUG(str[len-1]);DEBUG((str[0] != str[len-1]));
    if(str[0] != str[len-1]) f[0] = f[len-1]+1;
    // DEBUG(f[0]);DEBUG(f[len-1]);
    for(int i = 1;i < len;i++){
        if(str[i] != str[i-1]) f[i] = f[i-1]+1;
        else f[i] = 1;
    }
    int ans = 0;
    for(int i = 0;i < len;i++)
        ans = std::max(ans,f[i]);
    printf("%d\n",std::min(ans,len));
    return 0;
}


#include <algorithm>
#include <iostream>
#include <cstring>
#include <climits>
#include <cstdio>
#define DEBUG(x) std::cerr << #x << '=' << x << std::endl

namespace fastIO{
#define BUF_SIZE 100000
#define OUT_SIZE 100000
#define ll long long
    bool IOerror=0;
    inline char nc(){
        static char buf[BUF_SIZE],*p1=buf+BUF_SIZE,*pend=buf+BUF_SIZE;
        if (p1==pend){
            p1=buf; pend=buf+fread(buf,1,BUF_SIZE,stdin);
            if (pend==p1){IOerror=1;return -1;}
        }
        return *p1++;
    }
    inline bool blank(char ch){return ch==' '||ch=='\n'||ch=='\r'||ch=='\t';}
    inline void read(int &x){
        bool sign=0; char ch=nc(); x=0;
        for (;blank(ch);ch=nc());
        if (IOerror)return;
        if (ch=='-')sign=1,ch=nc();
        for (;ch>='0'&&ch<='9';ch=nc())x=x*10+ch-'0';
        if (sign)x=-x;
    }
    inline void read(ll &x){
        bool sign=0; char ch=nc(); x=0;
        for (;blank(ch);ch=nc());
        if (IOerror)return;
        if (ch=='-')sign=1,ch=nc();
        for (;ch>='0'&&ch<='9';ch=nc())x=x*10+ch-'0';
        if (sign)x=-x;
    }
#undef ll
#undef OUT_SIZE
#undef BUF_SIZE
};
using namespace fastIO;
#define DEBUG(x) std::cerr << #x << '=' << x << std::endl

const int MAXN = 100000 + 5;
int f[MAXN*3];

int main(){
    std::string str;
    std::cin >> str;
    int len = (unsigned)str.length();
    f[0] = 1;
    for(int i = 1;i < len;i++){
        if(str[i] != str[i-1]) f[i] = f[i-1]+1;
        else f[i] = 1;
    }
    // DEBUG(str[0]);DEBUG(str[len-1]);DEBUG((str[0] != str[len-1]));
    if(str[0] != str[len-1]) f[0] = f[len-1]+1;
    // DEBUG(f[0]);DEBUG(f[len-1]);
    for(int i = 1;i < len;i++){
        if(str[i] != str[i-1]) f[i] = f[i-1]+1;
        else f[i] = 1;
    }
    int ans = 0;
    for(int i = 0;i < len;i++)
        ans = std::max(ans,f[i]);
    printf("%d\n",std::min(ans,N));
    return 0;
}


#include <algorithm>
#include <iostream>
#include <cstring>
#include <climits>
#include <cstdio>
#define DEBUG(x) std::cerr << #x << '=' << x << std::endl

namespace fastIO{
#define BUF_SIZE 100000
#define OUT_SIZE 100000
#define ll long long
    bool IOerror=0;
    inline char nc(){
        static char buf[BUF_SIZE],*p1=buf+BUF_SIZE,*pend=buf+BUF_SIZE;
        if (p1==pend){
            p1=buf; pend=buf+fread(buf,1,BUF_SIZE,stdin);
            if (pend==p1){IOerror=1;return -1;}
        }
        return *p1++;
    }
    inline bool blank(char ch){return ch==' '||ch=='\n'||ch=='\r'||ch=='\t';}
    inline void read(int &x){
        bool sign=0; char ch=nc(); x=0;
        for (;blank(ch);ch=nc());
        if (IOerror)return;
        if (ch=='-')sign=1,ch=nc();
        for (;ch>='0'&&ch<='9';ch=nc())x=x*10+ch-'0';
        if (sign)x=-x;
    }
    inline void read(ll &x){
        bool sign=0; char ch=nc(); x=0;
        for (;blank(ch);ch=nc());
        if (IOerror)return;
        if (ch=='-')sign=1,ch=nc();
        for (;ch>='0'&&ch<='9';ch=nc())x=x*10+ch-'0';
        if (sign)x=-x;
    }
#undef ll
#undef OUT_SIZE
#undef BUF_SIZE
};
using namespace fastIO;
#define DEBUG(x) std::cerr << #x << '=' << x << std::endl

const int MAXN = 100000 + 5;
int f[MAXN*3];

int main(){
    std::string str;
    std::cin >> str;
    int len = (unsigned)str.length();
    f[0] = 1;
    for(int i = 1;i < len;i++){
        if(str[i] != str[i-1]) f[i] = f[i-1]+1;
        else f[i] = 1;
    }
    // DEBUG(str[0]);DEBUG(str[len-1]);DEBUG((str[0] != str[len-1]));
    if(str[0] != str[len-1]) f[0] = f[len-1]+1;
    // DEBUG(f[0]);DEBUG(f[len-1]);
    for(int i = 1;i < len;i++){
        if(str[i] != str[i-1]) f[i] = f[i-1]+1;
        else f[i] = 1;
    }
    int ans = 0;
    for(int i = 0;i < len;i++)
        ans = std::max(ans,f[i]);
    printf("%d\n",ans);
    return 0;
}


#define push_back pb
#define make_pair mk
#include<iostream>
#include<stdlib.h>
#include<stdio.h>
#include<cmath>
#include<map>
#include<algorithm>
#include<string>
#include<string.h>
#include<set>
#include<queue>
#include<stack>
#include<functional>
using std::pair;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,int>PII;
const double PI=acos(-1);
const int maxn = 2e5 + 10;
const int INF = 0x3f3f3f3f;
const int mod =1e9+7;
const ll inf =1e18;
using namespace std;
int main()
{
    string s;
    cin>>s;
    s+=s;
    int res=0;
    int n=s.length();
   // cout<<n<<endl;
    int ans=0;
    for(int i=1;i<n;i++)
    {
        if(s[i]!=s[i-1])
        {
            res++;
        }
        else
        {
            ans=max(ans,res);
            res=1;
        }
    }
    ans=max(ans,res);
    cout<<ans<<endl;
}


#define push_back pb
#define make_pair mk
#include<iostream>
#include<stdlib.h>
#include<stdio.h>
#include<cmath>
#include<map>
#include<algorithm>
#include<string>
#include<string.h>
#include<set>
#include<queue>
#include<stack>
#include<functional>
using std::pair;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,int>PII;
const double PI=acos(-1);
const int maxn = 2e5 + 10;
const int INF = 0x3f3f3f3f;
const int mod =1e9+7;
const ll inf =1e18;
using namespace std;
int main()
{
    string s;
    cin>>s;
    s+=s;
    int res=1;
    int n=s.length();
   // cout<<n<<endl;
    int ans=0;
    for(int i=1;i<n;i++)
    {
        if(s[i]!=s[i-1])
        {
            res++;
        }
        else
        {
            ans=max(ans,res);
            res=1;
        }
    }
    ans=max(ans,res);
    if(ans>n/2) cout<<n/2<<endl;
    else
    cout<<ans<<endl;
}


#define push_back pb
#define make_pair mk
#include<iostream>
#include<stdlib.h>
#include<stdio.h>
#include<cmath>
#include<map>
#include<algorithm>
#include<string>
#include<string.h>
#include<set>
#include<queue>
#include<stack>
#include<functional>
using std::pair;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,int>PII;
const double PI=acos(-1);
const int maxn = 2e5 + 10;
const int INF = 0x3f3f3f3f;
const int mod =1e9+7;
const ll inf =1e18;
using namespace std;
int main()
{
    string s;
    cin>>s;
    s+=s;
    int res=1;
    int n=s.length();
   // cout<<n<<endl;
    int ans=0;
    for(int i=1;i<n;i++)
    {
        if(s[i]!=s[i-1])
        {
            res++;
        }
        else
        {
            ans=max(ans,res);
            res=1;
        }
    }
    ans=max(ans,res);
    cout<<ans<<endl;
}


#define push_back pb
#define make_pair mk
#include<iostream>
#include<stdlib.h>
#include<stdio.h>
#include<cmath>
#include<map>
#include<algorithm>
#include<string>
#include<string.h>
#include<set>
#include<queue>
#include<stack>
#include<functional>
using std::pair;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,int>PII;
const double PI=acos(-1);
const int maxn = 2e5 + 10;
const int INF = 0x3f3f3f3f;
const int mod =1e9+7;
const ll inf =1e18;
using namespace std;
int main()
{
    string s;
    cin>>s;
    s+=s;
    int res=0;
    int n=s.length();
   // cout<<n<<endl;
    int ans=0;
    for(int i=1;i<n;i++)
    {
        if(s[i]!=s[i-1])
        {
            res++;
        }
        else
        {
            ans=max(ans,res);
            res=1;
        }
    }
    ans=max(ans,res);
    if(ans==1) cout<<"0"<<endl;
    else cout<<ans<<endl;
}


#include <bits/stdc++.h>

#define FOR(x, a, b) for (int x = a; x <= b; ++x)
#define FOD(x, a, b) for (int x = a; x >= b; --x)
#define REP(x, a, b) for (int x = a; x <  b; ++x)
#define DEBUG(X) { cout << #X << " = " << X << endl; }
#define PR(A, n) { cout << #A << " = "; FOR(_, 1, n) cout << A[_] << " "; cout << endl; }
#define PR0(A, n) { cout << #A << " = "; REP(_, 0, n) cout << A[_] << " "; cout << endl; }
#define BitCount(x) __builtin_popcountll(x)
#define y1 asdioayseiowqe12

using namespace std;

typedef long long LL;

const int N = 1e5 + 10;

int n;

char S[N];

int main() {
    #ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif // LOCAL
    scanf("%s", S + 1); n = strlen(S + 1);
    int ans = 0, d = 1, p = S[1];
    FOR(i, 2, 2 * n) {

        if (S[(i - 1) % n + 1] != p) ++d;
            else {
                ans = max(ans, d);
                d = 1;
            }
        p = S[(i - 1) % n + 1];
    }
    printf("%d", ans);
    return 0;

}


#include <bits/stdc++.h>

#define FOR(x, a, b) for (int x = a; x <= b; ++x)
#define FOD(x, a, b) for (int x = a; x >= b; --x)
#define REP(x, a, b) for (int x = a; x <  b; ++x)
#define DEBUG(X) { cout << #X << " = " << X << endl; }
#define PR(A, n) { cout << #A << " = "; FOR(_, 1, n) cout << A[_] << " "; cout << endl; }
#define PR0(A, n) { cout << #A << " = "; REP(_, 0, n) cout << A[_] << " "; cout << endl; }
#define BitCount(x) __builtin_popcountll(x)
#define y1 asdioayseiowqe12

using namespace std;

typedef long long LL;

const int N = 1e5 + 10;

int n;

char S[N];

int main() {
    #ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif // LOCAL
    scanf("%s", S + 1); n = strlen(S + 1);
    int ans = 0, d = 1, p = S[1];
    FOR(i, 2, 2 * n) {

        if (S[(i - 1) % n + 1] != p) ++d;
            else {
                ans = max(ans, d);
                d = 1;
            }
        p = S[(i - 1) % n + 1];
    }
    printf("%d", min(ans, n));
    return 0;

}


#include <bits/stdc++.h>

#define FOR(x, a, b) for (int x = a; x <= b; ++x)
#define FOD(x, a, b) for (int x = a; x >= b; --x)
#define REP(x, a, b) for (int x = a; x <  b; ++x)
#define DEBUG(X) { cout << #X << " = " << X << endl; }
#define PR(A, n) { cout << #A << " = "; FOR(_, 1, n) cout << A[_] << " "; cout << endl; }
#define PR0(A, n) { cout << #A << " = "; REP(_, 0, n) cout << A[_] << " "; cout << endl; }
#define BitCount(x) __builtin_popcountll(x)
#define y1 asdioayseiowqe12

using namespace std;

typedef long long LL;

const int N = 1e5 + 10;

int n;

char S[N];

int main() {
    #ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif // LOCAL
    scanf("%s", S + 1); n = strlen(S + 1);
    int ans = 0, d = 1, p = S[1];
    FOR(i, 2, 2 * n) {

        if (S[(i - 1) % n + 1] != p) ++d;
            else {
                ans = max(ans, d);
                d = 1;
            }
        p = S[(i - 1) % n + 1];
    }
    ans = max(ans, d);
    printf("%d", min(ans, n));
    return 0;

}


#include <bits/stdc++.h>
using namespace std;
const int N=101000;
int n,m,data[2*N],data2[2*N];
char str[2*N],str2[2*N];
int main(){
	int i,j;
	scanf("%s",str+1);
	int n=strlen(str+1);
	memset(data,0,sizeof(data));memset(data2,0,sizeof(data2));
	for (i=1;i<=n;i++) {
		if (str[i]=='w') data[i]=1;
		data[i+n]=data[i];data2[n-i+1]=data[i];
		data2[2*n-i+1]=data[i];
	}
	int ans1=0,ans2=0,ans=0;
	for (i=2;i<=2*n;i++){
		if (data[i]^data[i-1]) ans1++; else ans1=1;
		if (data2[i]^data2[i-1]) ans2++; else ans2=1;
		ans=max(ans,max(ans1,ans2));
	}
	printf("%d\n",ans);
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
const int N=101000;
int n,data[N],a[N],b[N];char str[N];
int main(){
	int i,j;
	scanf("%s",str+1);
	int n=strlen(str+1);
	memset(data,0,sizeof(data));
	for (i=1;i<=n;i++) if (str[i]=='w') data[i]=1;
	int tmp=1;a[1]=1;
	memset(a,0,sizeof(a));memset(b,0,sizeof(b));
	int ans=1;a[1]=1;
	for (i=2;i<=n;i++){
		if (data[i]^data[i-1]) tmp++;
		    else {b[++b[0]]=i;tmp=1;}
		a[i]=tmp;
		ans=max(ans,tmp);
	}
	//for (i=1;i<=n;i++) printf("%d ",a[i]);puts("");
	int ans1=0;
	for (i=1;i<=b[0];i+=2){
		ans1+=a[b[i]-1];
	}
	int ans2=0;
	for (i=2;i<=b[0];i+=2){
		ans2+=a[b[i]-1];
	}
	ans=max(ans,max(ans1,ans2));
	printf("%d\n",ans);
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
const int N=101000;
int n,m,data[2*N],data2[2*N];
char str[2*N],str2[2*N];
int main(){
	int i,j;
	scanf("%s",str+1);
	int n=strlen(str+1);
	memset(data,0,sizeof(data));memset(data2,0,sizeof(data2));
	for (i=1;i<=n;i++) {
		if (str[i]=='w') data[i]=1;
		data[i+n]=data[i];data2[n-i+1]=data[i];
		data2[2*n-i+1]=data[i];
	}
	int ans1=0,ans2=0,ans=0;
	for (i=2;i<=2*n;i++){
		if (data[i]^data[i-1]) ans1++; else ans1=1;
		if (data2[i]^data2[i-1]) ans2++; else ans2=1;
		ans=max(ans,max(ans1,ans2));
	}
	ans=min(ans,n);
	printf("%d\n",ans);
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
const int N=101000;
int n,data[N],a[N],b[N];char str[N];
int main(){
	int i,j;
	scanf("%s",str+1);
	int n=strlen(str+1);
	memset(data,0,sizeof(data));
	for (i=1;i<=n;i++) if (str[i]=='w') data[i]=1;
	int tmp=1;a[1]=1;
	memset(a,0,sizeof(a));memset(b,0,sizeof(b));
	int ans=1;
	for (i=2;i<=n;i++){
		if (data[i]^data[i-1]) tmp++;
		    else {ans=max(ans,tmp);b[++b[0]]=i;tmp=1;}
		a[i]=tmp;
	}
	int ans1=0;
	for (i=1;i<=b[0];i+=2){
		ans1+=a[b[i]-1];
	}
	int ans2=0;
	for (i=2;i<=b[0];i+=2){
		ans2+=a[b[i]-1];
	}
	ans=max(ans,max(ans1,ans2));
	printf("%d\n",ans);
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
const int N=101000;
int n,data[N],a[N],b[N];char str[N];
int main(){
	int i,j;
	scanf("%s",str+1);
	int n=strlen(str+1);
	memset(data,0,sizeof(data));
	for (i=1;i<=n;i++) if (str[i]=='w') data[i]=1;
	int tmp=1;a[1]=1;
	memset(a,0,sizeof(a));memset(b,0,sizeof(b));
	int ans=1;
	for (i=2;i<=n;i++){
		if (data[i]^data[i-1]) tmp++;
		    else {ans=max(ans,tmp);b[++b[0]]=i;tmp=1;}
		a[i]=tmp;
	}
	int ans1=0;
	for (i=1;i<=b[0];i+=2){
		ans1+=a[b[i]-1];
	}
	int ans2=0;
	for (i=2;i<=b[0];i+=2){
		ans2+=a[b[i]-1];
	}
	ans=max(ans1,ans2);
	printf("%d\n",ans);
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    while(cin>>s)
    {
        s+=s;
        int k=s.size();
        int ans=0,len=1;
        for(int i=1;i<k;i++)
        {
            if(s[i]!=s[i-1]) len++;
            else
            {
                ans=max(len,ans);
                len=1;
            }
        }
        ans=max(ans,len);
        cout<<min(ans,k/2)<<endl;
    }
    return 0;
}


#include<iostream>
#include<cstring>
#include<algorithm>
#include<map>
using namespace std;
int main()
{
    string s;
    while(cin>>s)
    {
        int ans=1,len=1;
        int k=s.size()-1;
        char l=s[0],r=s[k];
        int flag=0;
        for(int i=1;i<=k;i++)
        {
           if(s[i]!=s[i-1]) len++;
           else
           {
               if(l!=r)
               {
                   len++;
                   reverse(s.begin()+i,s.end());
                   swap(s[0],s[i-1]);
                   l=s[0];
                   r=s[k];
               }
               else
               {
                   flag=1;
                   ans=max(len,ans);
                   len=1;
                   for(int j=i+1;j<=k;j++)
                   {
                       if(s[j]!=s[j-1]) len++;
                       else
                       {
                           ans=max(ans,len);
                           len=1;
                       }
                   }
               }
           }
           if(flag) break;
        }
        ans=max(ans,len);
        cout<<ans<<endl;
    }
    return 0;
}


#include<iostream>
#include<cstring>
#include<algorithm>
#include<map>
using namespace std;
int main()
{
    string s;
    while(cin>>s)
    {
        int ans=1,len=1;
        int k=s.size()-1;
        char l=s[0],r=s[k];
        int flag=0;
        for(int i=1;i<=k;i++)
        {
           if(s[i]!=s[i-1]) len++;
           else
           {
               if(l!=r)
               {
                   len++;
                   reverse(s.begin()+i,s.end());
                   swap(s[0],s[i-1]);
                   l=s[0];
                   r=s[k];
               }
               else
               {
                   flag=1;
                   ans=max(len,ans);
                   len=1;
                   for(int j=i+1;j<=k;j++)
                   {
                       if(s[j]!=s[j-1]) len++;
                       else
                       {
                           ans=max(ans,len);
                           len=1;
                           j++;
                       }
                   }
               }
           }
           if(flag) break;
        }
        ans=max(ans,len);
        cout<<ans<<endl;
    }
    return 0;
}


#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

string s;

int main()
{
    //freopen("testcases.txt","r",stdin);
    cin>>s;
    s+=s;

    int mx=1;
    int cnt=1;

    for(int i=1;i<s.length();i++)    {
        if(s[i]!=s[i-1])    {
            cnt++;
        }
        else    {
            mx=max(mx,cnt);
            cnt=1;
        }
    }
    mx=max(mx,cnt);

    cout<<mx<<endl;

    return 0;
}


#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

string s;

int main()
{
    //freopen("testcases.txt","r",stdin);
    cin>>s;
    s+=s;

    int mx=1;
    int cnt=1;

    for(int i=1;i<s.length();i++)    {
        if(s[i]!=s[i-1])    {
            cnt++;
        }
        else    {
            mx=max(mx,cnt);
            cnt=1;
        }
    }
    mx=max(mx,cnt);
    mx=min(mx,(int)(s.length()/2));

    cout<<mx<<endl;

    return 0;
}


#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

string s;

int main()
{
    //freopen("testcases.txt","r",stdin);
    cin>>s;
    s+=s;

    int mx=1;
    int cnt=1;

    for(int i=1;i<s.length();i++)    {
        if(s[i]!=s[i-1])    {
            cnt++;
        }
        else    {
            mx=max(mx,cnt);
            cnt=1;
        }
    }

    cout<<mx<<endl;

    return 0;
}


#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdlib>
using namespace std;
char s[100000 + 5],len;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> (s + 1);
    int len = strlen(s + 1);
    int maxlen = 0;
    for(int i = 1;i < len;++i)
    if(s[i] != s[i + 1]){
		int tmp = 2;i++;
		while(s[i] != s[i + 1] && i < len)tmp++,i++;
		i--;
		maxlen = max(maxlen,tmp);
	}
	if(maxlen == len){cout << len;return 0;}
	if(s[1] != s[len]){
		int i,j;
		for(i = 1;i < len && s[i] != s[i + 1];++i);
		for(j = len;j > i + 1 && s[j] != s[j - 1];--j);
		maxlen = max(maxlen,i + (len - j + 1));
	}
	cout << min(maxlen,len) << endl;
    return 0;
}


#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdlib>
using namespace std;
#define LL long long
inline LL gcd(LL a,LL b){return b == 0 ? a : gcd(b,a % b);}
LL a[150005],b[150005];
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    LL pre = 0;
    for(int i = 1;i <= n;++i){
    	cin >> a[i] >> b[i];
    	if(a[i] < b[i])swap(a[i],b[i]);
    	LL tmp = a[i]/gcd(a[i],b[i]) * b[i];
   		if(!pre)pre = a[i] / gcd(a[i],b[i]) * b[i];
   		else pre = gcd(pre,tmp);
   		if(pre == 1){cout << -1;return 0;}
	}
	for(int i = 1;i <= n;++i){
		if(pre % a[i] == 0 &&a[i] != 1)pre = a[i];
		if(pre % b[i] == 0 &&b[i] != 1)pre = b[i];
	}

	cout << pre;
    return 0;
}


#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <string>
using namespace std;
string s;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> s;
    s = s + s;
    int len = s.length();
    int maxlen = 0;
    int tmp = 1;
    for(int i = 0;i < len - 1;++i)
    if(s[i] != s[i + 1]){
		tmp++;
	}
	else {
		maxlen = max(maxlen,tmp);
		tmp = 1;
	}
	maxlen = max(maxlen,tmp);
	cout << min(maxlen,len/2) << endl;
    return 0;
}


#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <string>
using namespace std;
string s;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> s;
    s = s + s;
    int len = s.length();
    int maxlen = 0;
    int tmp = 1;
    for(int i = 0;i < len - 1;++i)
    if(s[i] != s[i + 1]){
		tmp++;
	}
	else {
		maxlen = max(maxlen,tmp);
		tmp = 1;
	}
	cout << min(maxlen,len/2) << endl;
    return 0;
}


#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdlib>
using namespace std;
char s[100000 + 5],len;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> (s + 1);
    int len = strlen(s + 1);
    int maxlen = 0;
    for(int i = 1;i <= len;++i)
    if(s[i] != s[i + 1]){
		int tmp = 2;i++;
		while(s[i] != s[i + 1] && i < len)tmp++,i++;
		i--;
		maxlen = max(maxlen,tmp);
	}
	if(maxlen == len){cout << len;return 0;}
	if(s[1] != s[len]){
		int i,j;
		for(i = 1;i < len && s[i] != s[i + 1];++i);
		for(j = len;j > i + 1 && s[j] != s[j - 1];--j);
		maxlen = max(maxlen,i + (len - j + 1));
	}
	cout << min(maxlen,len) << endl;
    return 0;
}


#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
using namespace std;
string a;
char b[200005];
long long anst,ans;
long long maxx(long long a,long long b)
{
	return a>b?a:b;
}
int main()
{

	cin>>a;
	long long i,n=a.length();

	for(i=0;i<n;i++)
		//a[i+n]=a[i];
		b[i]=a[i],b[i+n]=a[i];

	long long t=0;

	while(t<(n*2-1))
	{
		//cout<<a[t];
		if(b[t]!=b[t+1])anst++;
		if(b[t]==b[t+1]&&anst!=0){ans=maxx(ans,anst+1);anst=0;}
		t++;
	}
	ans=maxx(ans,anst+1);
	if(ans<n)
	cout<<ans;
	else
	cout<<n;
	return 0;
}


#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
using namespace std;
string a;
long long anst,ans;
long long maxx(long long a,long long b)
{
	return a>b?a:b;
}
int main()
{

	cin>>a;
	long long i,pos;

	for(i=0;i<a.length();i++)
		a[i+a.length()]=a[i];

	long long t=0;

	while(t<a.length()*2-2)
	{
		if(a[t]!=a[t+1])anst++;
		if(a[t]==a[t+1]&&anst!=0)ans=maxx(ans,anst+1),anst=0;
		t++;
	}
	ans=maxx(ans,anst+1);
	if(ans>a.length())
	cout<<a.length();
	else
	cout<<ans;
	return 0;
}


#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
using namespace std;
string a;
int anst,ans;
int main()
{
	//int n=a.length();
	cin>>a;
	int i,mark=a[0],pos,t=0;
	//a[0]==a[a.length()-1]?pos=0:t=1;
	//if(t)
	for(i=0;i<a.length();i++)
	{
		a[i+a.length()]=a[i];
		//if(mark==a[i]){pos=i;break;}
		//else mark=a[i];
	}
	t=0;
	//cout<<n;
	while(t<=a.length()*2-1)
	{//cout<<t;
		/*if(pos==a.length()-1)
		{if(a[pos]!=a[0])anst++;
		if(a[pos]==a[0])ans=max(ans,anst),anst=0;
		}*/
		if(a[t]!=a[t+1])anst++;
		if(a[t]==a[t+1]&&anst!=0)ans=max(ans,anst+1),anst=0;
		t++;

	}
	if(ans>a.length())
	cout<<ans/2;
	else
	cout<<ans;
	return 0;
}


#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
using namespace std;
string a;
long long anst,ans;
long long maxx(long long a,long long b)
{
	return a>b?a:b;
}
int main()
{

	cin>>a;
	long long i,n=a.length();

	for(i=0;i<n;i++)
		a[i+n]=a[i];

	long long t=0;

	while(t<n*2-1)
	{
		//cout<<a[t];
		if(a[t]!=a[t+1])anst++;
		if(a[t]==a[t+1]&&anst!=0){ans=maxx(ans,anst+1);anst=0;}
		t++;
	}
	ans=maxx(ans,anst+1);
	if(ans>n)
	cout<<n;
	else
	cout<<ans;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
string a;
long long anst,ans;
long long maxx(long long a,long long b)
{
	return a>b?a:b;
}
int main()
{
	cin>>a;
	long long i,n=a.size();

	for(i=0;i<n;i++)
		a[i+n]=a[i];

	long long t=0;

	while(t<n*2-1)
	{
		//cout<<a[t];
		if(a[t]!=a[t+1])anst++;
		if(a[t]==a[t+1]&&anst!=0){ans=maxx(ans,anst+1);anst=0;}
		t++;
	}
	ans=maxx(ans,anst+1);
	if(ans>n) {
		cout<<n;
	}
	else
	cout<<ans;//cout << 1 << endl;
	return 0;
}


#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
using namespace std;
string a;
int anst,ans;
int main()
{
	//int n=a.length();
	cin>>a;
	int i,pos;
	//a[0]==a[a.length()-1]?pos=0:t=1;
	//if(t)
	for(i=0;i<a.length();i++)
	{
		a[i+a.length()]=a[i];
		//if(mark==a[i]){pos=i;break;}
		//else mark=a[i];
	}
	int t=0;
	//cout<<n;
	while(t<a.length()*2-1)
	{//cout<<t;
		/*if(pos==a.length()-1)
		{if(a[pos]!=a[0])anst++;
		if(a[pos]==a[0])ans=max(ans,anst),anst=0;
		}*/
		if(a[t]!=a[t+1])anst++;
		if(a[t]==a[t+1]&&anst!=0)ans=max(ans,anst+1),anst=0;
		t++;

	}
	if(ans>a.length())
	cout<<ans/2;
	else
	cout<<ans;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
string a;
long long anst,ans;
long long maxx(long long a,long long b)
{
	return a>b?a:b;
}
int main()
{
	cin>>a;
	long long i,n=a.size();
	a=a+a;
	long long t=0;
	while(t<n*2-1)
	{
		//cout<<a[t];
		if(a[t]!=a[t+1])anst++;
		if(a[t]==a[t+1]&&anst!=0){ans=maxx(ans,anst+1);anst=0;}
		t++;
	}
	ans=maxx(ans,anst+1);
	if(ans>n) {
		cout<<n;
	}
	else
	cout<<ans;//cout << 1 << endl;
	return 0;
}


#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
using namespace std;
string a;
long long anst,ans;
long long maxx(long long a,long long b)
{
	return a>b?a:b;
}
int main()
{
	//int n=a.length();
	cin>>a;
	long long i,pos;
	//a[0]==a[a.length()-1]?pos=0:t=1;
	//if(t)
	for(i=0;i<a.length();i++)
	{
		a[i+a.length()]=a[i];
		//if(mark==a[i]){pos=i;break;}
		//else mark=a[i];
	}
	long long t=0;
	//cout<<n;
	while(t<a.length()*2-1)
	{//cout<<t;
		/*if(pos==a.length()-1)
		{if(a[pos]!=a[0])anst++;
		if(a[pos]==a[0])ans=max(ans,anst),anst=0;
		}*/
		if(a[t]!=a[t+1])anst++;
		if(a[t]==a[t+1]&&anst!=0)ans=maxx(ans,anst+1),anst=0;
		t++;

	}
	if(ans>a.length())
	cout<<ans/2;
	else
	cout<<ans;
	return 0;
}


#include<iostream>
#include<cstdio>
#include<string>
using namespace std;
string a;
int anst,ans;
int main()
{
	//int n=a.length();
	cin>>a;
	int i,mark=a[0],pos,t=0;
	a[0]==a[a.length()-1]?pos=0:t=1;
	if(t)
	for(i=1;i<a.length();i++)
	{
		if(mark==a[i]){pos=i;break;}
		else mark=a[i];
	}
	t=0;
	//cout<<n;
	while(t<=a.length())
	{//cout<<t;
		/*if(pos==a.length()-1)
		{if(a[pos]!=a[0])anst++;
		if(a[pos]==a[0])ans=max(ans,anst),anst=0;
		}*/
		if(a[pos]!=a[pos+1])anst++;
		if(a[pos]==a[pos+1]&&anst!=0)ans=max(ans,anst+1),anst=0;

		pos++,t++;
		if(pos==a.length())
		pos=0;
	}
	cout<<ans;
	return 0;
}


#include <stdio.h>
#include <string.h>
#include <algorithm>
using namespace std;

int n;
char a[200010];

int main(void){
    int i, j, ans = 0;
    scanf("%s", a + 1);
    n = strlen(a + 1);
    for(i = 1; i <= n; i++) a[i + n] = a[i];
    for(i = 1; i <= 2 * n; i = j){
        for(j = i + 1; j <= 2 * n; j++){
            if(a[j] == a[j - 1]) break;
            ans = max(ans, j - i);
        }
    }
    printf("%d\n",min(ans + 1, n));
}


#include <stdio.h>
#include <string.h>
#include <algorithm>
using namespace std;

int n;
char a[200010];

int main(void){
    int i, j, ans = 0;
    scanf("%s", a + 1);
    n = strlen(a + 1);
    for(i = 1; i <= n; i++) a[i + n] = a[i];
    for(i = 1; i <= 2 * n; i = j){
        for(j = i + 1; j <= 2 * n; j++){
            if(a[j] == a[j - 1]) break;
            ans = max(ans, j - i);
        }
    }
    printf("%d\n",ans + 1);
}


#include <iostream>
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
string s;
int main()
{
    int n,i,t,Mx=0,ct=0;
    cin>>s;
    n=s.size();
    s=s+s;
    for(int i=1;s[i];i++)
    {
        if(s[i]!=s[i-1]) ct++;
        else ct=1;
        Mx=max(Mx,ct);
    }
    printf("%d\n",min(Mx,n));
    return 0;
}


#include <iostream>
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
string s;
int main()
{
    int n,i,t,Mx=0,ct=0;
    cin>>s;
    s=s+s;
    for(int i=1;s[i];i++)
    {
        if(s[i]!=s[i-1]) ct++;
        else ct=1;
        Mx=max(Mx,ct);
    }
    printf("%d\n",Mx);
    return 0;
}


#include <iostream>
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
string s;
int main()
{
    int n,i,t,Mx=0,ct=0;
    cin>>s;
    n=strlen(s);
    s=s+s;
    for(int i=1;s[i];i++)
    {
        if(s[i]!=s[i-1]) ct++;
        else ct=1;
        Mx=max(Mx,ct);
    }
    printf("%d\n",min(Mx,n));
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

string s;

int main()
{
    cin >> s;
    int n = s.length();
    if(n == 1){
        cout << 1;
        exit(0);
    }
    s = s + s;
    int maxi = 0;
    int i = 1;
    for(; i < s.length(); i++){
        int kq = 1;
        int lim = i + n - 1;
        while(s[i] != s[i-1] && i < lim) {kq++; i++;}
        //for(int j = i + 1; j <= i + n - 1; j++){
            //if(s[j] != s[j - 1]) kq++;
             //else break;
        maxi = max(maxi, kq);
    }
    cout << maxi;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

string s;

int main()
{
    cin >> s;
    int n = s.length();
    if(n == 1){
        cout << 1;
        exit(0);
    }
    s = s + s;
    int maxi = 0;
    int i = 1;
    for(; i < s.length(); i++){
        int kq = 1;
        while(s[i] != s[i-1] && i < s.length()) {kq++; i++;}
        //for(int j = i + 1; j <= i + n - 1; j++){
            //if(s[j] != s[j - 1]) kq++;
             //else break;
        maxi = max(maxi, kq);
    }
    cout << maxi;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

string s;

int main()
{
    cin >> s;
    int n = s.length();
    if(n == 1){
        cout << 1;
        exit(0);
    }
    s = s + s;
    int maxi = 0;
    int i = 1;
    for(; i < s.length();i++){
        int kq = 1;
        int lim = min(i + n - 1, 2*n);
        while(s[i] != s[i-1] && i < lim) {kq++; i++;}
        //for(int j = i + 1; j <= i + n - 1; j++){
            //if(s[j] != s[j - 1]) kq++;
             //else break;
        maxi = max(maxi, kq);
    }
    cout << maxi;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

string s;

int main()
{
    cin >> s;
    int n = s.length();
    if(n == 1){
        cout << 1;
        exit(0);
    }
    s = s + s;
    int maxi = 0;
    for(int i = 0; i < n; i++){
        int kq = 1;
        for(int j = i + 1; j <= i + n - 1; j++){
            if(s[j] != s[j - 1]) kq++;
             else break;
        }
        maxi = max(maxi, kq);
    }
    cout << maxi;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

string s;

int main()
{
    cin >> s;
    int n = s.length();
    if(n == 1){
        cout << 1;
        exit(0);
    }
    s = s + s;
    int maxi = 0;
    for(int i = 0; i < s.length(); i++){
        int kq = 1;
        for(int j = i + 1; j <= i + n - 1; j++){
            if(s[j] != s[j - 1]) kq++;
             else break;
        }
        maxi = max(maxi, kq);
    }
    cout << maxi;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

string s;

int main()
{
    cin >> s;
    int n = s.length();
    if(n == 1){
        cout << 1;
        exit(0);
    }
    s = s + s;
    int maxi = 0;
    int i = 1;
    for(; i < s.length(); i++){
        int kq = 1;
        int lim = max(i + n - 1, 2*n);
        while(s[i] != s[i-1] && i < lim) {kq++; i++;}
        //for(int j = i + 1; j <= i + n - 1; j++){
            //if(s[j] != s[j - 1]) kq++;
             //else break;
        maxi = max(maxi, kq);
    }
    cout << maxi;
    return 0;
}


#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
string a;
int f[200200];
int len,y;
int maxx=-1;
int main(){
	cin>>a;
	len=a.size();
	for(int i=0;i<a.size();i++){
		if(a[i]=='w'){
			f[i+1]=1;
		}
		else{
			f[i+1]=0;
		}
	}
	for(int i=len+1;i<=2*len;i++){
		f[i]=f[i-len];
	}
	int j=1,k=f[1],y=1;
	for(int i=2;i<=len*2;i++){
		if(f[i]!=k){
			y++;
			k=f[i];
		}
		else{
			maxx=max(maxx,y);
			j=i,y=1,k=f[i];
		}
	}
	maxx=max(maxx,y);
	if(maxx>len){
		cout<<len;
	}
	else{
		cout<<maxx;
	}
	return 0;
}


#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
string a;
int f[200200];
int len,y;
int maxx=-1;
int main(){
	cin>>a;
	len=a.size();
	for(int i=0;i<a.size();i++){
		if(a[i]=='w'){
			f[i+1]=1;
		}
		else{
			f[i+1]=0;
		}
	}
	for(int i=len+1;i<=2*len;i++){
		f[i]=f[i-len];
	}
	int j=1,k=f[1],y=1;
	for(int i=2;i<=len*2;i++){
		if(f[i]!=k){
			y++;
			k=f[i];
		}
		else{
			maxx=max(maxx,y);
			j=i,y=1,k=f[i];
		}
	}
	if(maxx>len){
		cout<<len;
	}
	else{
		cout<<maxx;
	}
	return 0;
}


#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<queue>
#include<vector>
#include<functional>
#include<cstdio>
#include<set>
using namespace std;

int main()
{
	string sr;
	while (cin >> sr)
	{
		int n = sr.length();
		sr = sr + sr;
		int ans = 1,Max =1 ;
		for (int i = 1;i<sr.length(); i++)
		{
			if (sr[i] != sr[i - 1])
			{
				ans++;
				if (ans > Max)
					Max = ans;
				if (Max == n) break;
			}
			else
			{
				ans = 1;
			}

		}
		cout << Max << endl;
	}
	return 0;
}


#include <cstdio>
#include <cstring>
#include <string>
#include <queue>
#include <set>
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long LL;

int main()
{
    string s;
    cin>>s;
    int len = s.length();
    s = s+s;
    int x = -1, ans = 1;
    if(len==1)
        x = 1;
    else
    {
        for(int i=0; i<2*len; i++)
        {
            if(s[i] != s[i+1])
            {
                ans++;
                x = max(x, ans);
                if(x==len)
                    break;
            }
            else
                ans=1;
        }
    }

    printf("%d\n", x);
    return 0;
}


#include <cstdio>
#include <cstring>
#include <string>
#include <queue>
#include <set>
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long LL;

int main()
{
    string s;
    cin>>s;
    int len = s.length();
    s = s+s;
    int x = -1, ans = 1;
    for(int i=0;i<2*len;i++)
    {
        if(s[i] != s[i+1])
        {
            ans++;
            x = max(x, ans);
            if(x==len)
                break;
        }
        else
            ans=1;
    }
    printf("%d\n", x);
    return 0;
}


#include <cstdio>
#include <cstring>
#include <string>
#include <queue>
#include <set>
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long LL;

int main()
{
    string s;
    cin>>s;
    int len = s.length();
    s = s+s;
    int x = 1, ans = 1;
//    if(len==1)
//        x = 1;
    //else
    //{
        for(int i=0; i<2*len-1; i++)
        {
            if(s[i] != s[i+1])
            {
                ans++;
                x = max(x, ans);
                if(x==len)
                    break;
            }
            else
                ans=1;
        }
    //}

    printf("%d\n", x);
    return 0;
}


#include <cstdio>
#include <cstring>
#include <string>
#include <queue>
#include <set>
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long LL;

int main()
{
    string s;
    cin>>s;
    int len = s.length();
    s = s+s;
    int x = -1, ans = 1;
    if(len==1)
        x = 1;
    else
    {
        for(int i=0; i<2*len-1; i++)
        {
            if(s[i] != s[i+1])
            {
                ans++;
                x = max(x, ans);
                if(x==len)
                    break;
            }
            else
                ans=1;
        }
    }

    printf("%d\n", x);
    return 0;
}


#include <iostream>
#include <string>
using namespace std;
string x;
int mx,c,nxt;
char two[3]={'b','w'};
int main(){
cin>>x;
x+=x;
if(x[0]=='b')nxt=1;
else nxt=0;
c=1;
for(int i=1;i<x.size();i++){
 if(x[i]==two[nxt]){
    c++;
    nxt++;
    nxt=(nxt%2);
 }
 else{
    c=1;
    if(x[i]=='b')nxt=1;
    else
    nxt=0;
 }
 mx=max(mx,c);

}
cout<<mx<<endl;
return 0;
}


#include <iostream>
#include <cmath>
#include <vector>
#include <map>
using namespace std;
const int N= 5e4, M= 150005;
bool p[N];
vector <int> ab[M];
int n,a,b,primes[5135],cn,temp;
map <int,bool> mp;
int solve(){
int j;
for(int i=0;i<ab[0].size();i++){
    if(ab[0][i]==0)
    continue;
   temp=ab[0][i];
    for( j=1;j<n;j++){
     if(ab[j][0]%temp==0||ab[j][1]%temp==0)
        continue;

     j=n*n;
    }
if(j==n)
return temp;
}

return -1;
}

int main(){
cin>>n;
cin>>a>>b;
int l=max(sqrt(a),sqrt(b));

for(int j=2;j<=sqrt(a);j++){
  if((a%j)==0)
  if(!mp.count(j)){
    for(int i=j+j;i<sqrt(a);i+=j)
      mp[i]=1;

    ab[0].push_back(j);
    if(!mp.count(a/j))
      ab[0].push_back(a/j);
  }
 else
  if(!mp.count(a/j))
    ab[0].push_back(a/j);

}
for(int j=2;j<=sqrt(b);j++){
  if((b%j)==0)
  if(!mp.count(j)){
    for(int i=j+j;i<sqrt(b);i+=j)
      mp[i]=1;

    ab[0].push_back(j);
    if(!mp.count(b/j))
      ab[0].push_back(b/j);
  }
 else
  if(!mp.count(b/j))
    ab[0].push_back(b/j);

}

for(int i=0;i<ab[0].size();i++){
    if(ab[0][i]==0)continue;
 for(int j=0;j<ab[0].size();j++){
    if(i==j)continue;
    if(ab[0][j]==0)continue;
  if((ab[0][j]%ab[0][i])==0) ab[0][j]=0;
}
}
ab[0].push_back(a);
ab[0].push_back(b);

for (int i=1;i<n;i++){
cin>>a>>b;
ab[i].push_back(a);
ab[i].push_back(b);
}
cout<<solve()<<endl;
}


#include <iostream>
#include <string>
using namespace std;
string x;
int mx,c,nxt;
char two[3]={'b','w'};
int main(){
cin>>x;
x+=x;
if(x[0]=='b')nxt=1;
else nxt=0;
c=1;
for(int i=1;i<x.size();i++){
 if(x[i]==two[nxt]){
    c++;
    nxt++;
    nxt=(nxt%2);
 }
 else{
    c=1;
    if(x[i]=='b')nxt=1;
    else
    nxt=0;
 }
 mx=max(mx,c);

}
if(mx>x.size()/2)
    mx=x.size()/2;

cout<<mx<<endl;
return 0;
}


#include<bits/stdc++.h>
using namespace std;
int n,i,j,ans;
char s[10000005];
int main()
{
    scanf("%s",s+1);
    n=strlen(s+1);
    for(i=1;i<=n;i++) s[i+n]=s[i];
    int tmp=n<<1;
    for(i=1;i<=tmp;i=j)
    {
        for(j=i+1;j<=tmp;j++)
			if(s[j]==s[j-1])
				break;
        ans=max(ans,j-i);
    }
    printf("%d",min(ans,n));
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
bool a[15000005];
string s;
int n=0;
int main()
{
	cin>>s;
	n=s.size();
	for(int i=1;i<=n;i++)
	{
		char tmpchar=s[i-1];
		if(tmpchar=='b') a[i]=1;
		else if(tmpchar=='w') a[i]=0;
		else break;
	}
	for(int i=n+1;i<=n*2;i++)
		a[i]=a[i-n];
	int maxn=0,nownow,tmpans=0;
	for(int i=1;i<=2*n;i++)
	{
		nownow=i,tmpans=1;
		while(true)
		{
			nownow++;
			if(a[nownow]==a[nownow-1])
			{
				break;
			}
			tmpans++;
		}
		maxn=max(maxn,tmpans);
	}
	printf("%d",min(maxn,n));
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
bool a[15000005];
string s;
int n=0;
int main()
{
	cin>>s;
	n=s.size();
	for(int i=1;i<=n;i++)
	{
		char tmpchar=s[i-1];
		if(tmpchar=='b') a[i]=1;
		else if(tmpchar=='w') a[i]=0;
		else break;
	}
	for(int i=n+1;i<=n*2;i++)
		a[i]=a[i-n];
	int maxn=0,nownow,tmpans=0;
	for(int i=1;i<=2*n;i++)
	{
		nownow=i,tmpans=1;
		while(true)
		{
			nownow++;
			if(nownow>2*n) break;
			if(a[nownow]==a[nownow-1])
			{
				break;
			}
			tmpans++;
		}
		maxn=max(maxn,tmpans);
	}
	printf("%d",min(maxn,n));
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
bool a[15000005];
string s;
int n=0;
int main()
{
	cin>>s;
	n=s.size();
	for(int i=1;i<=n;i++)
	{
		char tmpchar=s[i-1];
		if(tmpchar=='b') a[i]=1;
		else if(tmpchar=='w') a[i]=0;
		else break;
	}
	for(int i=n+1;i<=n*2;i++)
		a[i]=a[i-n];
	int maxn=0,nownow,tmpans=0;
	for(int i=1;i<=2*n;i++)
	{
		if(2*n-i<maxn) break;
		nownow=i,tmpans=1;
		while(true)
		{
			nownow++;
			if(nownow>2*n) break;
			if(a[nownow]==a[nownow-1])
			{
				break;
			}
			tmpans++;
		}
		maxn=max(maxn,tmpans);
	}
	printf("%d",min(maxn,n));
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
bool a[15000005];
string s;
int n=0;
int main()
{
	cin>>s;
	n=s.size();
	for(int i=1;i<=n;i++)
	{
		char tmpchar=s[i-1];
		if(tmpchar=='b') a[i]=1;
		else if(tmpchar=='w') a[i]=0;
		else break;
	}
	for(int i=n+1;i<=n*2;i++)
		a[i]=a[i-n];
	int maxn=0,nownow,tmpans=0;
	for(int i=1;i<=2*n;i++)
	{
		if(2*n-i<maxn) break;
		nownow=i,tmpans=1;
		while(true)
		{
			nownow++;
			if(a[nownow]==a[nownow-1])
			{
				break;
			}
			tmpans++;
		}
		maxn=max(maxn,tmpans);
	}
	printf("%d",min(maxn,n));
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
bool a[150005];
string s;
int n=0;
int main()
{
	cin>>s;
	n=s.size();
	for(int i=1;i<=n;i++)
	{
		char tmpchar=s[i-1];
		if(tmpchar=='b') a[i]=1;
		else if(tmpchar=='w') a[i]=0;
		else break;
	}
	for(int i=n+1;i<=n*2;i++)
		a[i]=a[i-n];
	int maxn=0,nownow,tmpans=0;
	for(int i=1;i<=2*n;i++)
	{
		nownow=i,tmpans=1;
		while(true)
		{
			nownow++;
			if(a[nownow]==a[nownow-1])
			{
				break;
			}
			tmpans++;
		}
		maxn=max(maxn,tmpans);
	}
	printf("%d",min(maxn,n));
	return 0;
}


#include<algorithm>
#include<iostream>
#include<string.h>
#include<sstream>
#include<stdio.h>
#include<iomanip>
#include<math.h>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#define  mem(a,b) memset(a,b,sizeof(a))

const int mo=1000000007;
const int inf=0x3f3f3f3f;
double pi=3.14159265358979323846;
double e= 2.71828182845904523536;
typedef long long ll;
using namespace std;

void read(int &x) {
    int f = 1; x = 0;
    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();}
    x *= f;
}

string s;
int main()
{
    cin>>s;
    string a=s+s;
    int ans=1;
    int cnt=1;
    for(int i=1;i<a.length();i++)
    {
        if(a[i]!=a[i-1])
        {
            cnt++;
            ans=max(ans,cnt);
        }
        else
            cnt=1;
    }
    cout<<ans<<endl;
    return 0;
}


#include<algorithm>
#include<iostream>
#include<string.h>
#include<sstream>
#include<stdio.h>
#include<iomanip>
#include<math.h>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#define  mem(a,b) memset(a,b,sizeof(a))

const int mo=1000000007;
const int inf=0x3f3f3f3f;
double pi=3.14159265358979323846;
double e= 2.71828182845904523536;
typedef long long ll;
using namespace std;

void read(int &x) {
    int f = 1; x = 0;
    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();}
    x *= f;
}

string s;
int main()
{
    cin>>s;
    string a=s+s;
    int ans=0;
    int cnt=1;
    for(int i=1;i<a.length();i++)
    {
        if(a[i]!=a[i-1])
        {
            cnt++;
            ans=max(ans,cnt);
        }
        else
            cnt=1;
    }
    cout<<ans<<endl;
    return 0;
}


#include<algorithm>
#include<iostream>
#include<string.h>
#include<sstream>
#include<stdio.h>
#include<iomanip>
#include<math.h>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#define  mem(a,b) memset(a,b,sizeof(a))

const int mo=1000000007;
const int inf=0x3f3f3f3f;
double pi=3.14159265358979323846;
double e= 2.71828182845904523536;
typedef long long ll;
using namespace std;

void read(int &x) {
    int f = 1; x = 0;
    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();}
    x *= f;
}

string s;
int main()
{
    cin>>s;
    int n=s.size();
    s+=s;
    int ans=1;
    int cnt=1;
    for(int i=1;i<s.size();i++)
    {
        if(s[i]!=s[i-1])
        {
            cnt++;
            ans=max(ans,cnt);
        }
        else
            cnt=1;
    }
    cout<<min(ans,n)<<endl;
    return 0;
}


#include<algorithm>
#include<iostream>
#include<string.h>
#include<sstream>
#include<stdio.h>
#include<iomanip>
#include<math.h>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#define  mem(a,b) memset(a,b,sizeof(a))

const int mo=1000000007;
const int inf=0x3f3f3f3f;
double pi=3.14159265358979323846;
double e= 2.71828182845904523536;
typedef long long ll;
using namespace std;

void read(int &x) {
    int f = 1; x = 0;
    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();}
    x *= f;
}

string s;
int main()
{
    cin>>s;
    s+=s;
    int ans=0;
    int cnt=1;
    for(int i=1;i<s.size();i++)
    {
        if(s[i]!=s[i-1])
            cnt++;
        else
        {
            ans=max(ans,cnt);
            cnt=1;
        }
    }
    cout<<ans<<endl;
    return 0;
}


#include<algorithm>
#include<iostream>
#include<string.h>
#include<sstream>
#include<stdio.h>
#include<iomanip>
#include<math.h>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#define  mem(a,b) memset(a,b,sizeof(a))

const int mo=1000000007;
const int inf=0x3f3f3f3f;
double pi=3.14159265358979323846;
double e= 2.71828182845904523536;
typedef long long ll;
using namespace std;

void read(int &x) {
    int f = 1; x = 0;
    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();}
    x *= f;
}

string s;
int main()
{
    cin>>s;
    string a=s+s;
    int ans=0;
    int cnt=1;
    for(int i=1;i<a.length();i++)
    {
        if(a[i]!=a[i-1])
            cnt++;
        else
        {
            ans=max(ans,cnt);
            cnt=1;
        }
    }
    cout<<ans<<endl;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
char s[200005];
int n;
int main(){
  scanf("%s",s+1);
  n=strlen(s+1);
  int ans=1;
  int Ans=1;
  for (int i=1;i<=n;i++)s[i+n]=s[i];
  for (int i=1;i<=2*n-1;i++){
    if (s[i+1]!=s[i])ans++;
    else ans=1;
    Ans=max(ans,Ans);
  }
  printf("%d\n",min(n,Ans));
}


#include <bits/stdc++.h>
using namespace std;
char s[200005];
int n;
int main(){
  scanf("%s",s+1);
  n=strlen(s+1);
  int ans=1;
  int Ans=0;
  for (int i=1;i<=n;i++)s[i+n]=s[i];
  for (int i=1;i<=2*n-1;i++){
    if (s[i+1]!=s[i]){
      ans++;
      Ans=max(ans,Ans);
    }
    else ans=1;
  }
  printf("%d\n",min(n,Ans));
}


#include <bits/stdc++.h>
using namespace std;
char s[100005];
int n;
int main(){
  scanf("%s",s+1);
  n=strlen(s+1);
  int ans=1;
  int Ans=0;
  for (int i=1;i<=n;i++)s[i+n]=s[i];
  for (int i=1;i<=2*n-1;i++){
    if (s[i+1]!=s[i]){
      ans++;
      Ans=max(ans,Ans);
    }
    else ans=1;
  }
  printf("%d\n",min(n,Ans));
}


#include<bits/stdc++.h>
using namespace std;
int main(){
	int i,cnt;
	string s;
	cin>>s;
	s+=s;
	int len=s.length();
	int mx=0;
	for(i=1;i<len;i++){
		cnt=0;
		while(s[i]!=s[i-1]&&i<len){
		     cnt++;
			 i++;
		}
		if(cnt) cnt++;
		if(cnt>len/2) cnt=len/2;
		mx=max(mx,cnt);
	}
	printf("%d\n",mx);
	return 0;
}


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

int main(){
	int cnt;
	string s;
	cin>>s;
	s+=s;
	int len=s.length();
	int mx=0;
	for(int i=1;i<len;i++){
        cnt=0;
        while(s[i]!=s[i-1]&&i<len){
            cnt++;
            i++;
		}
		if(cnt) cnt++;
		mx=max(mx,cnt);
	}
	mx=min(mx,len);
	printf("%d\n",mx);
	return 0;
}


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

int main(){
	int cnt;
	string s;
	cin>>s;
	s+=s;
	int len=s.length();
	int mx=1;
	for(int i=1;i<len;i++){
        cnt=0;
        while(s[i]!=s[i-1]&&i<len){
            cnt++;
            i++;
		}
		if(cnt) cnt++;
		mx=max(mx,cnt);
	}
	printf("%d\n",mx);
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
	int cnt;
	string s;
	cin>>s;
	s+=s;
	int len=s.length();
	int mx=1;
	for(int i=1;i<len;i++){
        cnt=0;
        while(s[i]!=s[i-1]&&i<len){
            cnt++;
            i++;
		}
		if(cnt) cnt++;
		mx=max(mx,cnt);
	}
	mx=min(mx,len/2);
	printf("%d\n",mx);
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int maxn=2e5+10;
struct sci{
    int lis,lok;
}movie[maxn];
map<int,int>can;
int n,m;
int most;
int ans1,ans;
bool yes=0;
int main(){
    cin>>n;
    for(int i=1,x;i<=n;i++){
        cin>>x;
        can[x]++;
    }
    cin>>m;
    for(int i=1;i<=m;i++){
        cin>>movie[i].lis>>movie[i].lok;
    }
    for(map<int,int>::iterator it=can.begin();it!=can.end();it++){
        if(most<it->second){
            most=it->second;
            ans1=it->first;
        }
    }
    for(int i=1;i<=m;i++){
        if(movie[i].lis==ans1){
            if(yes){
                if(can[movie[ans].lok]<can[movie[i].lok]){
                    ans=i;
                }
            }
            else ans=i,yes=1;
        }
    }
    cout<<ans;
}


#include <iostream>
#include <cstdio>
#include <cstring>
#include <queue>
#include <cmath>
#include <algorithm>
#include <map>
#define ll long long
#define rei register int
#define bl putchar(' ')
#define ed putchar('\n')
#define Min(a,b) ((a)<(b)?(a):(b))
#define Max(a,b) ((a)>(b)?(a):(b))
#define Mabs(a,b) ((a)>(b)?(a)-(b):(b)-(a))
#define Abs(a) ((a)>0?(a):-(a))
#define test std::cout<<"this:"
#define inf 0x7f7f7f7f
#define dinf 0x3f3f3f3f
#define llinf 0x7f7f7f7f7f7f7f7f
#define lldinf 0x3f3f3f3f3f3f3f3f
#define pai acos(-1)
#define inv inline void
#define card system("pause")
#define read2(a,b) read(a),read(b)
#define read3(a,b,c) read(a),read(b),read(c)
template <typename QvQ>inv read(QvQ &x)
{
	x=0;int f=1;
	char c=getchar();
	for(;c<'0'||c>'9';c=getchar()) if(c=='-') f=-1;
	for(;c>='0'&&c<='9';c=getchar()) x=(x<<1)+(x<<3)+(c^48);
	x=x*f;
}
template <typename QvQ>inv write(QvQ x)
{
	if(x<0) x=-x,putchar('-');
	if(x>9) write(x/10);
	putchar(x%10+'0');
}
std::map<int,int> num;int temp,t2,n,m;
int main()
{
	int a1=0,a2=0,aout=1;
	read(n);
	for(rei i=1;i<=n;++i) read(temp),++num[temp];
	read(m);
	for(rei i=1;i<=m;++i)
	{
		read2(temp,t2);
		if(num[temp]>a1)
		{
			a1=num[temp];
			a2=num[t2];
			aout=i;
		}
		else if(num[temp]==a1)
		{
			if(num[t2]>a2)
			{
				a2=num[t2];
				aout=i;
			}
		}
	}
	write(aout);
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int maxx=200005;
int a[maxx];
int s[200005],cnt,bb;
struct node{
	int t,tt,h;
}b[maxx];
map<int,int> ma;
bool cmp(node x,node y){
//	if(s[a.t]==s[c.t])
//		return a.tt>c.tt;
//	return a.t>c.t;
	return x.t>y.t||x.t==y.t&&x.tt>y.tt;
}
int main()
{
	int n,m;
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d",&a[i]);
		ma[a[i]]++;
	}
	scanf("%d",&m);
	for(int i=1;i<=m;i++) scanf("%d",&bb),b[i].t=ma[bb],b[i].h=i;
	for(int i=1;i<=m;i++) scanf("%d",&bb),b[i].tt=ma[bb];
	sort(b+1,b+m+1,cmp);
	printf("%d",b[1].h);
	return 0;
}


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

int n,m,ma;
int a[20001],b[20001],c[20001];
map<int,int> mo;
int main()
{
	std::ios::sync_with_stdio(false);
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		mo[a[i]]++;
	}
	cin>>m;
	for(int i=1;i<=m;i++)
	cin>>b[i];
	for(int i=1;i<=m;i++)
	cin>>c[i];

	for(int i=1;i<=m;i++)
	{
		b[i]=mo[b[i]];
		c[i]=mo[c[i]];
	}
	ma=1;
	for(int i=1;i<=m;i++)
	{
		if(b[i]>b[ma])
		ma=i;
	}
	for(int i=1;i<=m;i++)
	{
		if(b[i]==b[ma]&&c[i]>c[ma])
		ma=i;
	}
	cout<<ma;
	return 0;
}


#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
const int maxn = 2e5 + 100;
int a[maxn];
int b[maxn];
int cnt;
int voice[maxn];
int word[maxn];
int c[maxn];
int main()
{
    int n, m;
    scanf("%d", &n);
    for (int i = 1; i <= n;i++)
    {
        scanf("%d", &a[i]);
    }
    sort(a + 1, a + n + 1);
    for (int i = 1; i <= n;i++)
    {
        if(i==1||a[i]!=a[i-1])
            b[++cnt] = a[i];
    }
    scanf("%d", &m);
    for (int i = 1; i <= m;i++)
        scanf("%d", &voice[i]);
    for (int i = 1; i <= m;i++)
        scanf("%d", &word[i]);
    for (int i = 1; i <= n;i++)
    {
        int v = a[i];
        int p = lower_bound(b + 1, b + cnt + 1, v) - b;
        c[p]++;
    }
    int maxx = -1;
    int ans = -1;
    int tmpans = -1;
    for (int i = 1; i <= m;i++)
    {
        int v = voice[i];
        int p = lower_bound(b + 1, b + cnt + 1, v) - b;
        if(b[p]!=v)
            continue;
        if(c[p]>maxx)
        {
            maxx = c[p];
            ans = i;
            int vv = word[i];
            int pp = lower_bound(b + 1, b + cnt + 1, vv) - b;
            tmpans = c[pp];
        }
        else if (c[p]==maxx)
        {
            int vv = word[i];
            int pp = lower_bound(b + 1, b + cnt + 1, vv) - b;
            if(c[pp]>tmpans)
            {
                ans = i;
                tmpans = c[pp];
            }
            else
                continue;
        }
    }
    printf("%d\n", ans);
    return 0;
}


#include <iostream>
#include <map>
#include <vector>
using namespace std;

map<int, int> id;
int curid=0;
vector<int> man, voi, text;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	int n,m;
	cin >> n;
	int num;
	for(int i=0; i<n; i++){
		cin >> num;
		if(id.count(num)==0){
			id[num] = curid++;
		}
		man.push_back(id[num]);
	}
	cin >> m;
	for(int i=0; i<m; i++){
		cin >> num;
		if(id.count(num)==0){
			id[num] = curid++;
		}
		voi.push_back(id[num]);
	}
	for(int i=0; i<m; i++){
		cin >> num;
		if(id.count(num)==0){
			id[num] = curid++;
		}
		text.push_back(id[num]);
	}
	int ans1=0, ans2=0;
	int result=0;
	for(int i=0; i<m; i++){
		int a1=0;
		int a2=0;
		for(int j=0; j<n; j++){
			if(man[j]==voi[i]){
				a1++;
			}
			if(man[j]==text[i]){
				a2++;
			}
		}

		//cout << a1 << ' ' << a2 << endl;

		if((a1 > ans1) || ((a1==ans1) && (a2>ans2))){
			result = i;
			ans1 = a1;
			ans2 = a2;
		}
	}
	cout << result+1 << endl;
}


#include<cstdio>//compile with -std=c++11
#include<unordered_map>
using namespace std;
int n,m,mova[200005],movs[200005];
unordered_map<int,int> lang;
inline int read() {
    int s=0,w=1;
    char ch=getchar();
    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;
}
int main() {
    n=read();
    for(int i=1;i<=n;i++) lang[read()]+=1;
    m=read();
    for(int i=1;i<=m;i++) mova[i]=read();
    for(int i=1;i<=m;i++) movs[i]=read();
    int besti=1,bestp=0,bests=0;
    for(int i=1;i<=m;i++) {
        int a=lang[mova[i]],s=lang[movs[i]];
        if(a==bestp&&s>bests)
            besti=i,bests=s;
        else if(a>bestp)
            besti=i,bestp=a,bests=s;
    }
    printf("%d",besti);
    return 0;
}//测试！！


#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cmath>
using namespace std;
int n,m,ln,a[600005],c[600005],L[600005],pn[600005];

struct Data                           //结构体
{
	int wz,l,st;
}b[200005];

void discrete()                       //离散化
{
	sort(a+1,a+n+2*m+1);
	for (int i=1;i<=n+m*2;i++)
	  if (a[i]!=a[i-1])L[++ln]=a[i];
	return ;
}

bool pd(Data a1,Data a2)              //结构体快排的判断函数
{
	if (a1.l==a2.l)return a1.st>a2.st;
	else return a1.l>a2.l;
}

int query(int aa)                     //寻找的离散化后的下标
{
	return lower_bound(L+1,L+1+ln,aa)-L;
}

int main()
{
	cin>>n;
	for (int i=1;i<=n;i++)cin>>c[i];
	sort(c+1,c+1+n);
	for (int i=1;i<=n;i++)a[i]=c[i];
	cin>>m;
	for (int i=1;i<=m;i++)
	{
		cin>>b[i].l;
		a[n+i]=b[i].l;
		b[i].wz=i;
	}
	for (int i=1;i<=m;i++)
	{
		cin>>b[i].st;
		a[n+m+i]=b[i].st;
	}
	discrete();
	for (int i=1;i<=n;i++)pn[(query(c[i]))]++;
	for (int i=1;i<=m;i++)
	{
		b[i].l=pn[query(b[i].l)];
		b[i].st=pn[query(b[i].st)];
	}
	sort(b+1,b+1+m,pd);
	cout<<b[1].wz<<endl;
	return 0;
}


#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
const int maxn = 4e5+5;
int a[maxn],b[maxn],c[maxn+maxn>>1],d[maxn],e[maxn+maxn>>1],s[maxn];
int n,m,t,ans = 1,ans1,ans2;
void discrete(int x){
	int num = 0;
	sort(c+1,c+1+x);
	for(int i = 1;i <= x;i++)
		if(i == 1 || c[i] != c[i-1])e[++num] = c[i];
	e[0] = num;
}
int query(int x){
	int l = 1,r = e[0];
	while(l < r){
		int mid = (l+r)>>1;
		if(e[mid] >= x)r = mid;
		else l = mid+1;
	}
	return l;
}
int main(){
	cin>>n;
	for(int i = 1;i <= n;i++)scanf("%d",&a[i]),c[++t] = a[i];
	cin>>m;
	for(int i = 1;i <= m;i++)scanf("%d",&b[i]),c[++t] = b[i];
	for(int i = 1;i <= m;i++)scanf("%d",&d[i]),c[++t] = d[i];
	discrete(t);
	for(int i = 1;i <= n;i++)s[query(a[i])]++;
	for(int i = 1;i <= m;i++){
		int x = s[query(b[i])],y = s[query(d[i])];
		if(x > ans1 || (x == ans1 && y > ans2))ans = i,ans1 = x,ans2 = y;
	}
	cout<<ans<<endl;
	return 0;
}


#include<bits/stdc++.h>
#define N 1e9+1
#define M 200009
using namespace std;
typedef long long ll;
int n,m,b[M],c[M],mp[N],mx_b=0,mx_c=0,mx_ind;
int main(){
	cin>>n;
	for(int i=0;i<n;i++){
		int a;
		cin>>a;
		mp[a]++;
	}
	cin>>m;
	for(int i=1;i<=m;i++)cin>>b[i];
	for(int i=1;i<=m;i++)cin>>c[i];
	for(int i=1;i<=m;i++)
		if(mx_b<mp[b[i]]||mx_b==mp[b[i]]&&mx_c<mp[c[i]]){
			mx_b=mp[b[i]];
			mx_c=mp[c[i]];
			mx_ind=i;
		}
	cout<<max(1,mx_ind);
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int N,M,mova[200005],movs[200005];
map<int,int> lang;
inline int read()
{
    int r=0;
    char ch=getchar();
    while(ch<'0' || ch>'9')ch=getchar();
    while(ch>='0' && ch<='9')r=r*10+ch-'0',ch=getchar();
    return r;
}
int main()
{
    N=read();
    for(int i=1;i<=N;i++)lang[read()]+=1;
    M=read();
    for(int i=1;i<=M;i++)mova[i]=read();
    for(int i=1;i<=M;i++)movs[i]=read();
    int bestI=1,bestP=0,bestS=0;
    for(int i=1;i<=M;i++)
    {
        int a=lang[mova[i]],s=lang[movs[i]];
        if(a==bestP && s>bestS)bestI=i,bestS=s;
        else if(a>bestP)bestI=i,bestP=a,bestS=s;
    }
    printf("%d",bestI);
}


#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for (register int i = (a); i <= (b); i++)

const int maxn = 2e5 + 5, maxm = 6e5 + 5;;

int n, m, ans, cnt = 0, max_b = 0, max_c = 0;
int a[maxn], b[maxn], c[maxn], tot[maxn], disc[maxm];

int read() {
    int x = 0, flag = 0;
	char ch = ' ';
	while (ch != '-' && (ch < '0' || ch > '9')) ch = getchar();
	if (ch == '-') {
		flag = 1;
		ch = getchar();
	}
	while (ch >= '0' && ch <= '9') {
		x = (x << 1) + (x << 3) + ch - '0';
		ch = getchar();
	}
	return flag ? -x : x;
}

void write(int x) {
	if (x < 0) {
		putchar('-');
		x = -x;
	}
	if (x > 9) write(x / 10);
	putchar(x % 10 + '0');
}

int main() {
	n = read();
	rep(i, 1, n) disc[++cnt] = a[i] = read();
	m = read();
	rep(i, 1, m) {
		disc[++cnt] = b[i] = read();
		disc[++cnt] = c[i] = read();
	}
	sort(disc + 1, disc + cnt + 1);
	int q = unique(disc + 1, disc + cnt + 1) - (disc + 1);
	rep(i, 1, n) a[i] = lower_bound(disc + 1, disc + q + 1, a[i]) - disc;
	rep(i, 1, m) {
		b[i] = lower_bound(disc + 1, disc + q + 1, b[i]) - disc;
		c[i] = lower_bound(disc + 1, disc + q + 1, c[i]) - disc;
	}
	rep(i, 1, n) tot[a[i]]++;
	rep(i, 1, m) {
		if (tot[b[i]] > max_b) {
			max_b = tot[b[i]];
			max_c = tot[c[i]];
			ans = i;
		}
		else if (max_b == tot[b[i]] && max_c < tot[max_c]) {
			max_c = tot[max_c];
			ans = i;
		}
	}
	write(ans);
	return 0;
}


#include<iostream>
#include<cmath>
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;

const int maxn=100010;
int n,m;
int a[maxn],b[maxn];
int cnt;
int maxx;
int ans;

struct movie{
	int b;
	int c;
}mo[maxn];

struct nu{
	int id;
	int sum;
}num[maxn];

bool cmp(nu x,nu y){
	return x.sum>y.sum;
}

int main(){
	cin>>n;
	for(int i=1;i<=n;i++) cin>>a[i];
	for(int i=1;i<=n;i++){
		num[a[i]].sum++;
		num[a[i]].id=a[i];
	}
	cin>>m;
	for(int i=1;i<=m;i++) cin>>mo[i].b;
	for(int i=1;i<=m;i++) cin>>mo[i].c;
	sort(num+1,num+1+n,cmp);
	for(int i=1;i<=m;i++){
		if(mo[i].b==num[1].id&&mo[i].c>maxx){
			ans=i;
			maxx=mo[i].c;
		}
	}
	cout<<ans<<endl;
	return 0;
}


#include<cstdio>
#include<algorithm>
using namespace std;
struct node
{
	int z,p;
	node(){z=0;p=1;}
}a[200005];
int b[200005];
bool cmp(node n1,node n2){return n1.z<n2.z;}
int n,m,ans=1,mns=0,zns=0;
int find(int fuck)
{
	int l=1,r=n,bns=1;
	while(l<=r)
	{
		int mid=(l+r)>>1;
		if(a[mid].z==fuck)return mid;
		else if(a[mid].z<fuck)l=mid+1;
		else r=mid-1;
	}
	return 0;
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d",&a[i].z);
	scanf("%d",&m);
	for(int i=1;i<=m;i++)scanf("%d",&b[i]);
	sort(a+1,a+n+1,cmp);
	int last=1,len=1;
	while(last<n)
	{
		last++;
		if(a[last].z==a[len].z)a[len].p++;
		else a[++len].z=a[last].z;
	}
	n=len;
	for(int j=1,v;j<=m;j++)
	{
		scanf("%d",&v);
		int nows=0,nowz=0;
		nows=a[find(b[j])].p;
		if(nows<mns)continue;
		else if(nows>mns)
		{
			ans=j;
			mns=nows;
			v=find(v);
			nowz=a[v].p;
			zns=nowz;
		}
		else
		{
			v=find(v);
			nowz=a[v].p;
			if(nowz>zns){zns=nowz;ans=j;}
		}
	}
	printf("%d\n",ans);
	return 0;
}
/*
6
1 2 2 3 3 3
3
1 3 3
2 1 2
*/


#include<bits/stdc++.h>
using namespace std;
int n,m,a[200005],b[200005],c[200005],sum[200005],cnt,ans,maxs,k,i;
map<int,int> mpk;
int main()
{
	cin>>n;
	for(i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		if(!mpk[a[i]])
		mpk[a[i]]=++cnt;
		sum[mpk[a[i]]]++;
	}
	cin>>m;
	for(i=1;i<=m;i++)
	{
		scanf("%d%d",&b[i],&c[i]);
		int s=sum[mpk[b[i]]]+sum[mpk[c[i]]];
		if(s>=maxs&&sum[mpk[b[i]]]>k)
		{
			maxs=s;
			k=sum[mpk[b[i]]];
			ans=i;
		}
	}
	cout<<ans;
}


#include<map>
#include<set>
#include<stack>
#include<deque>
#include<queue>
#include<cmath>
#include<bitset>
#include<vector>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<fstream>
#include<iostream>
#include<algorithm>
#define inf 2139062143
#define re register
#define ll long long
#define ull unsigned long long
#define lowbit(x) x&-x
#define Flj(i,a,b) for(int i=(a);i;i=(b))
#define Fze(i,a,b) for(int i=(a);i<(b);i++)
#define For(i,a,b) for(int i=(a);i<=(b);i++)
#define Fer(i,a,b) for(int i=(a);i>=(b);i--)
#define Fer1(i,a,b) for(int i=(a);i>b;i--)
#define Dfor(i,a,b,k) for(double i=(a);i<(b);i+=k)
#define Qmax priority_queue
#define Qmin priority_queue<int,vector<int>,greater<int> >
using namespace std;
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;
}
const int maxn=2e5+10;
int n,m,A,B;
vector<int> v;
int ans,maxx,maxy,a[maxn],b[maxn],c[maxn],k[maxn];
int getid(int x){return lower_bound(v.begin(),v.end(),x)-v.begin()+1;}
int main(){
	n=read();For(i,1,n) a[i]=read(),v.push_back(a[i]);
	m=read();
	For(i,1,m) b[i]=read(),v.push_back(b[i]);
	For(i,1,m) c[i]=read(),v.push_back(c[i]);
	sort(v.begin(),v.end());
	v.erase(unique(v.begin(),v.end()),v.end());
	For(i,1,n) A=getid(a[i]),++k[A];
	For(i,1,m){
		A=getid(b[i]);B=getid(c[i]);
		if(k[A]>maxx){maxx=k[A];maxy=k[B];ans=i;}
		else if(k[A]==maxx&&k[B]>maxy){maxy=k[B];ans=i;}
	}
	printf("%d",ans);
}


#include<cstdio>
#include<algorithm>
#include<cstdlib>
using namespace std;
const int maxn=200000;
struct d{
	int data;
	int ind;
	int rank;
};
d aa[3*maxn+10];
int c[maxn+10];
int n,m,cnt=0;
bool cmp1(const d &x,const d &y){
	return x.data<y.data;
}
bool cmp2(const d &x,const d &y){
	return x.ind<y.ind;
}
int sum[maxn+10]={0};
int a[maxn+10],b[maxn+10],d[maxn+10];
bool vis[maxn+10]={0};
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d",&a[i]);
		aa[++cnt].data=a[i];
		aa[cnt].ind=cnt;
	}
	scanf("%d",&m);
	for(int i=1;i<=m;i++){
		scanf("%d",&b[i]);
		aa[++cnt].data=b[i];
		aa[cnt].ind=cnt;
	}
	for(int i=1;i<=m;i++){
		scanf("%d",&d[i]);
		aa[++cnt].data=d[i];
		aa[cnt].ind=cnt;
	}
	sort(aa+1,aa+cnt+1,cmp1);
	int tot=1;aa[1].rank=1;
	for(int i=2;i<=cnt;i++){
		if(aa[i].data!=aa[i-1].data){
			tot++;
			c[tot]=aa[i].data;
		}
		aa[i].rank=tot;
	}
	sort(aa+1,aa+cnt+1,cmp2);
	for(int i=1;i<=n;i++)a[i]=aa[i].rank;
	for(int i=n+1;i<=n+m;i++)b[i-n]=aa[i].rank;
	for(int i=n+m+1;i<=n+m+m;i++)d[i-n-m]=aa[i].rank;
	for(int i=1;i<=n;i++)sum[a[i]]++;
	int max1=0,max2=0,ind=-1;
	for(int i=1;i<=m;i++){
		if(sum[b[i]]>max1){
			max1=sum[b[i]];
			max2=sum[d[i]];
			ind=i;
		}
		else if(sum[b[i]]==max1&&sum[d[i]]>max2){
			max1=sum[b[i]];
			max2=sum[d[i]];
			ind=i;
		}
	}
	if(ind==-1)ind=1;
	printf("%d",ind);
	return 0;
}


#include<stdio.h>
#include<bits/stdc++.h>
#define ll long long//其实并不需要开long long
using namespace std;
int n,m;
struct node
{
	int more,most;
	ll ID;//最后输出编号，故存储下标。
};
node poi[200005];
bool cmp(node a,node b)//结构体排序常规操作。
{
	if(a.most==b.most)return a.more>b.more;
	return a.most>b.most;
}
map<ll,int> mp;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		int a;//节省空间，从我做起。
		scanf("%d",&a);
		mp[a]++;
	}
	scanf("%d",&m);
	for(int i=1;i<=m;i++)
	{
		int b;
		scanf("%d",&b);
		poi[i].most=mp[b];
		poi[i].ID=i;
	}
	for(int i=1;i<=m;i++)
	{
		int c;
		scanf("%d",&c);
		poi[i].more=mp[c];
	}
	sort(poi+1,poi+1+m,cmp);
	printf("%lld",poi[1].ID);// 从大到小排序，故输出第一项。
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int n,m,tot,sum,ansa,ansb,ans;
int a[200010],voice[200010],word[200010],c[900010],d[200010];
//c[]用于离散化
void discrete(){//离散化到c[]
    sort(d+1,d+tot);
    for (int i = 1; i < tot+1; i++)
    {
        if (i==1 || d[i]!=d[i-1])
        {
            c[++sum] = d[i];
        }
    }
}

int find(int x){
    return lower_bound(c+1,c+sum+1,x)-c;
    //返回x在c[]中的位置（编号）
}

int main()
{
    cin>>n;

    for (int i = 1; i < n+1; i++)
    {
        cin >> a[i];
        d[++tot] = a[i];
    }

    cin>>m;

    for (int i = 1; i < m+1; i++)
    {
        cin>> voice[i];
        d[++tot] = voice[i];
    }

    for (int i = 1; i < m+1; i++)
    {
        cin >> word[i];
        d[++tot] = word[i];
    }

    discrete();

    for (int i = 1; i < n+1; i++)
    {
        c[ find(a[i]) ] ++;
    }

    for (int i = 1; i < m+1; i++)
    {
        int k=c[ find(voice[i]) ];
        int l=c[ find(word[i]) ];
        if(k > ansa || (k == ansa && l > ansb ) ){
            ansa = k;
            ansb = l;
            ans = i;
        }
    }

    cout<<ans;

    return 0;
}


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

int n,m;
const int maxn = 2e5+5;
int a[maxn];
int b[maxn];
int sc[maxn];

struct Mo
{
    int b;
    int c;
    int id;
} mov[maxn];

bool cmp(Mo a,Mo b)
{
    if(a.b == b.b)
        return a.c > b.c;
    return a.b > b.b;
}
int query(int x,int len)
{
    return lower_bound(b+1,b+1+len,x)-b;
}
int main()
{
    scanf("%d",&n);
    for(int i=1; i<=n; i++)scanf("%d",&a[i]);
    sort(a+1,a+1+n);
    int tmp;
    int len = 0;
    for(int i=1;i<=n;i++)
    {
        if(i==1 || a[i] != a[i-1])
            b[++len] = a[i];
    }
   // for(int i=1;i<=len;i++)printf("%d---\n",b[i]);
    for(int i=1;i<=n;i++)
    {
        tmp = query(a[i],len);
        sc[tmp]++;
    }

    for(int i=1;i<=len;i++)printf("%d---\n",sc[i]);
    scanf("%d",&m);
    for(int i=1; i<=m; i++)
    {
        scanf("%d",&tmp),mov[i].id = i;
        int pos  = query(tmp,len);
        if(b[pos] == tmp)mov[i].b = sc[tmp];
        else mov[i].b = 0;
    }
    for(int i=1; i<=m; i++)
    {
        scanf("%d",&tmp);
        int pos = query(tmp,len);
        if(b[pos] == tmp)mov[i].c = sc[tmp];
        else mov[i].c = 0;
    }
    sort(mov+1,mov+1+m,cmp);
    printf("%d\n",mov[1].id);
}


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

int n,m,a[200005],ans;
struct node
{
	int id,b,c,f1,f2;
	node(){f1=f2=0;}
}q[200005];

bool cmp_b(node x,node y){return x.b<y.b;}
bool cmp_c(node x,node y){return x.c<y.c;}
bool cmp_f(node x,node y)
{
	if(x.f1^y.f1)return x.f1>y.f1;
	else return x.f2>y.f2;
}

int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;++i)scanf("%d",&a[i]);
	scanf("%d",&m);
	for(int i=1;i<=m;++i)
	{
		scanf("%d",&q[i].b);
		q[i].id=i;
	}
	for(int i=1;i<=m;++i)scanf("%d",&q[i].c);
	sort(q+1,q+1+m,cmp_b);
	for(int i=1;i<=n;++i)
	{
		int l=1,r=m,mid;
		while(l<=r)
		{
			mid=(l+r)>>1;
			if(q[mid].b>=a[i])ans=mid,r=mid-1;
			else l=mid+1;
		}
		while(q[ans].b==a[i]&&ans<=m)++q[ans].f1,++ans;
	}
	sort(q+1,q+1+m,cmp_c);
	for(int i=1;i<=n;++i)
	{
		int l=1,r=m,mid;
		while(l<=r)
		{
			mid=(l+r)>>1;
			if(q[mid].c>=a[i])ans=mid,r=mid-1;
			else l=mid+1;
		}
		while(q[ans].c==a[i]&&ans<=m)++q[ans].f2,++ans;
	}
	sort(q+1,q+1+m,cmp_f);
	printf("%d",q[1].id);
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int maxn=2e5+10;
int can[maxn],can1[maxn],neww[maxn];
struct movi{
    int yuyin,zimu;
}movie[maxn];
int n,m;
int most=-1,most1,ans;

int main(){
    ios::sync_with_stdio(false);
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>can[i];can1[i]=can[i];
    }
    sort(&can[1],&can[n+1]);
    int len=unique(&can[0],&can[n+1])-can;
    //cout<<len<<"\n";
    for(int i=1;i<=n;i++){
        int pos=lower_bound(&can[1],&can[len],can1[i])-can;
        neww[pos]++;
    }
    //for(int i=0;i<len;i++)cout<<can[i]<<" ";
    //cout<<"\n";
    cin>>m;
    for(int i=1;i<=m;i++)cin>>movie[i].yuyin;
    for(int i=1;i<=m;i++)cin>>movie[i].zimu;
    for(int i=1;i<=m;i++){
        int x,y;
        int pos=upper_bound(&can[1],&can[len+1],movie[i].yuyin)-can;
        if(pos==len)x=0;
        else x=neww[pos];
        if(most<x){
            int pos1=upper_bound(&can[1],&can[len+1],movie[i].zimu)-can;
            if(pos1==len)y=0;
            else y=neww[pos];
            most=x;ans=i;most1=y;
        }
        else if(most==x){
            int pos1=upper_bound(&can[1],&can[len+1],movie[i].zimu)-can;
            if(pos1==len)y=0;
            else y=neww[pos];
            if(y>most1){
                most1=y;ans=i;
            }
        }
    }
    cout<<ans;
}


#include <cstdio>
#include <algorithm>

using namespace std;

inline int read() {
	int num = 0;
	char c = getchar();
	while (c < '0' || c > '9') c = getchar();
	while (c >= '0' && c <= '9')
		num = num * 10 + c - '0', c = getchar();
	return num;
}

const int maxn = 2e5 + 5;

int a[maxn], b[maxn], p[maxn], cnt[maxn];

int main() {
	int n = read();
	for (int i = 1; i <= n; ++i) a[i] = b[i] = read();
	sort(b + 1, b + n + 1);
	b[0] = unique(b + 1, b + n + 1) - b - 1;
	for (int i = 1; i <= n; ++i)
		++cnt[a[i] = lower_bound(b + 1, b + b[0] + 1, a[i]) - b];
	int m = read(), ans, ans_p = -1, ans_q = -1;
	for (int i = 1; i <= m; ++i) p[i] = read();
	for (int i = 1; i <= m; ++i) {
		int q = read(), pos1, pos2, x = 0, y = 0;
		pos1 = lower_bound(b + 1, b + b[0] + 1, p[i]) - b;
		pos2 = lower_bound(b + 1, b + b[0] + 1, q) - b;
		if (b[pos1] == p[i]) x = cnt[pos1];
		if (b[pos2] == q) y = cnt[pos2];
		if (x > ans_p) ans = i, ans_p = x, ans_q = y;
		else if (x == ans_p && y > ans_q) ans = i, ans_p = x, ans_q = y;
	}
	printf("%d", ans);
	return 0;
}


#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#define N 200020
using namespace std;
int n,m,lan[N],sum[N],num[N],len;
struct	movie{
	int q_a;
	int q_b;
	int hao;
}mov[N];
void san(){
	sort(lan + 1,lan + 1 + n);
	int head = 1;
	for(int i = 1;i <= n;i ++)
		if(i == 1 || lan[i] != lan[i - 1] )
	      num[++len] = lan[i];
	for(int i = 1;i <= n;i ++){
		if(num[head] == lan[i])sum[head] ++;
		else sum[++head] ++;
	}
/*
	puts("---");
	for(int i = 1;i <= len;i ++)
		printf("%d %d\n",num[i],sum[i]);
	puts("---");
*/
}
int cha(int tim){
	int l = 1,r = len;
	if(tim < num[1] || tim > num[len])return 0;
	while(l < r){
		int mid = (l + r) >> 1;
		if(num[mid] < tim &&num[mid + 1] > tim)return 0;
		if(num[mid] > tim &&num[mid - 1] < tim)return 0;
		if(tim > num[mid])l = mid + 1;
		else r = mid ;
	}
	return sum[r];
}
int cmp(movie a,movie b){
	if(a.q_a > b.q_a)return 1;
	if(a.q_a < b.q_a)return 0;
	if(a.q_b > b.q_b)return 1;
	else return 0;
}
int main(){
	scanf("%d",&n);
	for(int i = 1;i <= n;i ++)
		scanf("%d",&lan[i]);
	san();
	scanf("%d",&m);
	int tim = 0;
	for(int i = 1;i <= m;i ++){
		scanf("%d",&tim);
		mov[i].hao = i;
		mov[i].q_a = cha(tim);
	}
	for(int i = 1;i <= m;i ++){
		scanf("%d",&tim);
		mov[i].q_b = cha(tim);
	}
	sort(mov + 1,mov + m + 1,cmp);
	printf("%d\n",mov[1].hao);
//	for(int i = 1;i <= m;i ++)
//		printf("%d %d %d\n",mov[i].hao,mov[i].q_a,mov[i].q_b);
	return 0;

}


#include<bits/stdc++.h>
using namespace std;
const int MAXN=200000+10;
int a[MAXN],b[MAXN],c[MAXN];
int temp[MAXN];
int N,M;
int binary_search(int x){
	int l=0,r=N;
	while(l!=r){
		int mid=(l+r)>>1;
		if(temp[mid]<x)l=mid;
		else r=mid-1;
		if(temp[r]==x&&temp[r-1]!=x)return r;
		if(temp[l]!=x&&temp[l+1]==x)return l+1;
		if(l+1==r&&temp[l]!=x&&temp[r]!=x)return MAXN-1;
	}
	return l+1;
}
int cnt[MAXN];
int sum[MAXN];
int main(){
	scanf("%d",&N);
	for(int i=1;i<=N;i++)
	{
		scanf("%d",&a[i]);
		temp[i]=a[i];
	}
	scanf("%d",&M);
	for(int i=1;i<=M;i++)
	scanf("%d",&b[i]);
	for(int i=1;i<=M;i++)
	scanf("%d",&c[i]);
	sort(temp+1,temp+N+1);
	for(int i=1;i<=M;i++)
	{
		b[i]=binary_search(b[i]);
		c[i]=binary_search(c[i]);
	}
	for(int i=1;i<=N;i++)
	a[i]=binary_search(a[i]);
	for(int i=1;i<=N;i++)
	sum[a[i]]++;
	for(int i=1;i<=M;i++)
	if(b[i]==c[i])cnt[b[i]]++;
	int u=0;
	for(int i=1;i<=M;i++)
	if(sum[b[i]]>sum[b[u]]||(sum[b[i]]>=sum[b[u]]&&sum[c[i]]-cnt[c[i]]>sum[c[u]]-cnt[c[u]]))u=i;
	printf("%d\n",u);
	return 0;
}


#include<cstdio>
#include<algorithm>
#include<iostream>
using namespace std;
int m,n;//films people
int pep[200005],fm1[200005],fm2[200005],nbs[600005],wkd[600005];
int pepwtd[600005],anss[600005];
int query(int x){
	return lower_bound(wkd+1,wkd+1+wkd[0],x)-wkd-1;
}
bool cmp(int a,int b){
	int a1=query(fm1[a]),a2=query(fm2[a]),b1=query(fm1[b]),b2=query(fm2[b]);
	if(pepwtd[a1]==pepwtd[b1]){
		if(pepwtd[b1]==pepwtd[b2])return a<b;
		return pepwtd[b1]>pepwtd[b2];
	}
	else {
		return pepwtd[a1]>pepwtd[b1];
	}
}
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;++i){
		scanf("%d",&pep[i]);
		nbs[++nbs[0]]=pep[i];
	}
	scanf("%d",&m);
	for(int i=1;i<=m;++i){
		scanf("%d",&fm1[i]);
		nbs[++nbs[0]]=fm1[i];
	}
	for(int i=1+m;i<=m+m;++i){
		scanf("%d",&fm2[i]);
		nbs[++nbs[0]]=fm2[i];
	}
	sort(nbs+1,nbs+1+nbs[0]);
	for(int i=1;i<=nbs[0];++i){
		if(nbs[i]!=nbs[i-1]||i==1){
			wkd[++wkd[0]]=nbs[i];
			anss[wkd[0]]=wkd[0];
		}
	}
	for(int i=1;i<=n;++i)pepwtd[lower_bound(wkd+1,wkd+1+wkd[0],pep[i])-wkd-1]++;
	sort(anss+1,anss+1+wkd[0],cmp);
	printf("%d\n",anss[1]);
	return 0;
}


#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#define reg register
using namespace std;

int n,a[200001];
int m,b[200001],c[200001];
int d[600001];
int tag[600001];
int mx=1;
int main(){
	ios::sync_with_stdio(false);
	cin>>n;
	int cnt=0;
	for(reg int i=1;i<=n;i++){
		cin>>a[i];
		d[++cnt]=a[i];
	}
	cin>>m;
	for(reg int i=1;i<=m;i++){
		cin>>b[i];
		d[++cnt]=b[i];
	}
	for(reg int i=1;i<=m;i++){
		cin>>c[i];
		d[++cnt]=c[i];
	}
	sort(d+1,d+1+cnt);
	memset(tag,0,sizeof(tag));
	int uni=unique(d+1,d+1+cnt)-(d+1);
	for(reg int i=1;i<=n;i++){
		a[i]=lower_bound(d+1,d+1+uni,a[i])-d;
		tag[a[i]]++;
	}
	for(reg int i=1;i<=m;i++){
		b[i]=lower_bound(d+1,d+1+uni,b[i])-d;
		c[i]=lower_bound(d+1,d+1+uni,c[i])-d;
	}

	int maxcount=-1;
	int maxcount2=-1;
	int movie=0;
	for(reg int i=1;i<=uni;i++){
		//int count=tag[b[i]];
		if(tag[b[i]]>maxcount){
			maxcount=tag[b[i]];
			maxcount2=tag[c[i]];
			movie=i;
		}
		if(tag[b[i]]==maxcount){
			if(tag[c[i]]>maxcount2){
				maxcount2=tag[c[i]];
				movie=i;
			}
		}
	}
	cout<<movie;
}


#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
const int N = 200000 ;
int a[N], b[N], c[N], d[N * 3 + 5], k[N * 3];
int n, m, idx, idx1;
int ans, ans1, ans2;

int query(int x) {
    return lower_bound(d, d + idx1, x) - d;
}

int main() {

    cin >> n;

    for(int i = 0; i < n; i++) {
        scanf("%d", &a[i]);
        d[idx++] = a[i];
    }

    cin >> m;

    for(int i = 0; i < m; i++) {
        scanf("%d", &b[i]);
        d[idx++] = b[i];
    }

    for(int i = 0 ; i < m; i++) {
        scanf("%d", &c[i]);
        d[idx++] = c[i];
    }

    sort( d, d + idx) ;

    for(int i = 0; i < idx; i++) {
        if(i == 0 || d[i] != d[i-1])
            d[idx1++] = d[i];
    }

    for(int i = 0 ; i < n; i++) k[query(a[i])]++;

    for(int i = 0; i < m; i++) {
        int x = k[query(b[i])], y = k[query(c[i])];
        if( x > ans1 || x == ans1 && y > ans2) {
            ans1 = x, ans2 = y, ans = i;
        }
    }

    cout << ans + 1;

    return 0;
}


#include <iostream>
#include <cstdio>
#include <map>
#include <tr1/unordered_map>

#define rint register int
#define readint(x) scanf("%d",&(x))
#define putint(x) printf("%d ",(x))
#define sys system("pause")
using namespace std;
using namespace std::tr1;
const int maxn = 200000 + 2;
const int maxm = 200000 + 2;

unordered_map<int,int> ma;
int n , m, t;
int voil[maxm] , worl[maxm];
int ans = 1 , anv , anw;

int main()
{
	readint(n);
	for(rint i=1; i<=n; i++){
		readint(t);
		ma[t]++;
	}
	readint(m);
	for(rint i=1; i<=m; i++) readint(voil[i]);
	for(rint i=1; i<=m; i++) readint(worl[i]);

	anv = ma[voil[1]] , anw = ma[worl[1]];
	for(rint i=1; i<=m; i++){
		int iv = ma[voil[i]] , iw = ma[worl[i]];
		if((iv > anv) || (iv == anv&&iw > anw)){
			ans = i;
			anv = iv;
			anw = iw;
		}
	}

	cout << ans;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int n,m;
int a[200010];
int cnt[800010];
int b[800010],c[800010];
int t1,t2,ans;
inline int init()
{
	int s=0,w=1;
	char ch=getchar();
	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;
}
int main()
{
    n=init();
    for(int i=1;i<=n;i++)
    {
    	a[i]=init();
    	cnt[a[i]%800000]++;
	}
	m=init();
	for(int i=1;i<=m;i++)
	{
	    int x=init();
		b[i]=x%800000;
	}
	for(int i=1;i<=m;i++)
	{
	    int x=init();
		c[i]=x%800000;
	}
	for(int i=1;i<=m;i++)
	{
		if(cnt[b[i]]>t1)
		{
			t1=cnt[b[i]];
			t2=cnt[c[i]];
			ans=i;
		}
		if(cnt[b[i]]==t1)
		{
			if(cnt[c[i]]>t2)
			{
				t2=cnt[b[i]];
				ans=i;
			}
		}
	}
	printf("%d\n",ans);
	return 0;
}


// luogu-judger-enable-o2
#include<bits/stdc++.h>
using namespace std;int n,l[600005],a[200005],m;struct film{	int sound;	int light;}good[200005];int main(){	map<int,int>p;	cin>>n;	for(int i=1;i<=n;i++){cin>>a[i];		p[a[i]]+=1;	}	cin>>m;	for(int i=1;i<=m;i++){		cin>>good[i].sound;	}	for(int i=1;i<=m;i++){		cin>>good[i].light;	}	int d=1;	for(int i=2;i<=m;i++){		if((p[good[i].sound]>p[good[d].sound])||(p[good[i].sound]==p[good[d].sound])&&p[good[i].light]>p[good[d].light]) d=i;	}	cout<<d<<endl;	return 0;}


// luogu-judger-enable-o2
#include<bits/stdc++.h>
using namespace std;
const int N=200005;
unordered_map<int,int> m1;
int n,m,a[N],b[N],c[N],ans=-1;
int main(){
    cin>>n;
    for(int i=0;i<n;i++) cin>>a[i],m1[a[i]]++;
    cin>>m;
    for(int i=0;i<m;i++) cin>>b[i];
    for(int i=0;i<m;i++) cin>>c[i];
    ans=0;
    for(int i=0;i<m;i++){
        if(m1[b[i]]>m1[b[ans]]) ans=i;
        else if(m1[b[i]]==m1[b[ans]]&&m1[c[i]]>m1[c[ans]]) ans=i;
    }
    cout<<ans+1;
    return 0;
}


#include<cstdio>
#include<algorithm>
int n,m,tot,k,ans,anscv,anssub;
int sci[200010],cv[200010],sub[200010],lang[600010],p[600010];//p[]表示会每种语言的人数

int query(int x){
    return std::lower_bound(lang+1,lang+k+1,x)-lang;
}

void read(){
    scanf("%d",&n);
    for(int i=1;i<=n;++i){
        scanf("%d",sci+i);
        lang[++tot]=sci[i];
    }
    scanf("%d",&m);
    for(int i=1;i<=m;++i){
        scanf("%d",cv+i);
        lang[++tot]=cv[i];
    }
    for(int i=1;i<=m;++i){
        scanf("%d",sub+i);
        lang[++tot]=sub[i];
    }
}

int main(){
    read();

    std::sort(lang+1,lang+tot+1);
    k=std::unique(lang+1,lang+tot+1)-(lang+1);

    for(int i=1;i<=n;++i){
        p[query(sci[i])]++;
    }
    for(int i=1;i<=m;++i){
        int tcv=p[query(cv[i])],tsub=p[query(sub[i])];
        if(tcv>anscv || (tcv==anscv && tsub>anssub)){
            ans=i;
            anscv=tcv;
            anssub=tsub;
        }
    }

    printf("%d",ans);
    return 0;
}


#include<cstdio>
#include<algorithm>
using namespace std;
int a[100000005];
struct node
{
	int x;
	int y;
}Node[100000005];
bool cmp(node a,node b)
{
	if(a.x<b.x)
		return a.x>b.x;
	else if(a.x==b.x)
	{
		if(a.y<=b.y)
			return a.y>b.y;
		else
			return a.y>b.y;
	}
	else
		return a.x<b.x;
}
int ans1,ans2,ans3=100000005;
int main()
{
	int n,m;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
	}
	sort(a,a+n+1);
	scanf("%d",&m);
	for(int i=1;i<=m;i++)
	{
		scanf("%d",&Node[i].x);
	}
	for(int i=1;i<=m;i++)
	{
		scanf("%d",&Node[i].y);
	}
	sort(Node,Node+m+1,cmp);
	int pos=1;
	for(int i=1;i<=m;i++)
	{
		long long k1=0,k2=0,k3=0;
		for(int j=1;j<=n;j++)
		{
			/*if(b[i]==a[j])
			{
				k1++;
			}
			if(c[i]==a[j])
			{
				k2++;
			}
			if(b[i]!=a[j]&&c[i]!=a[j])
			{
				k3++;
			}*/
			if(a[j]==Node[i].x)
			{
				k1++;
			}
			if(a[j]==Node[i].y)
			{
				k2++;
			}
			if(a[j]!=Node[i].x&&a[j]!=Node[i].y)
			{
				k3++;
			}
			if(a[j]>Node[i].x)
			{
				if(k1<ans1)
				{
					break;
				}
			}
			if(a[j]>Node[i].y)
			{
				if(k1<ans1&&k2<ans2)
					break;
			}
		}
		//cout<<k1<<" "<<k2<<endl;
		if(k1>ans1)
		{
            ans1=k1;
            ans2=k2;
            ans3=k3;
            pos=i;
        }
        else if(k1==ans1)
        {
            if(k2>ans2)
			{
				ans1=k1;
				ans2=k2;
				ans3=k3;
				pos=i;
			}
            else if(k2==ans2)
			{
				if(k3<ans3)
				{
					ans1=k1;
					ans2=k2;
					ans3=k3;
					pos=i;
				}
			}
        }
	}
	printf("%d",pos);
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
struct CINEMA{
	int zi;
	int yin;
}pian[201000];
int ren[201000],m,n,ans=0,text=0;
int a[601000],b[601000],tong[601000],z[201000]; int t=0;
void lisan()
{
	sort(a+1,a+1+2*m+n);
	for(int i=1;i<=n+2*m;i++)
		if(i==1||a[i]!=a[i-1]) b[++t]=a[i];
}
int query(int x)
{
	return lower_bound(b+1,b+1+t,x)-b;
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&ren[i]);
		a[i]=ren[i];
	}
	cin>>m;
	for(int i=1;i<=m;i++)
	{
		scanf("%d",&pian[i].yin);
		a[i+n]=pian[i].yin;
	}
	for(int i=1;i<=m;i++)
	{
		scanf("%d",&pian[i].zi);
		a[i+n+m]=pian[i].zi;
	}
	lisan();
	for(int i=1;i<=n;i++)
		tong[query(ren[i])]++;
	for(int i=1;i<=m;i++)
		if(tong[query(pian[i].yin)]>ans)
			ans=tong[query(pian[i].yin)];
	for(int i=1;i<=m;i++)
		if(tong[query(pian[i].yin)]==ans) z[++text]=i;
	int y=0,ji=0;
	for(int i=1;i<=text;i++)
	{
		if(tong[query(pian[z[i]].zi)]>y)
		{
			y=tong[query(pian[z[i]].zi)];
			ji=z[i];
		}
	}
	printf("%d",ji);
	return 0;
}


#include<bits/stdc++.h>
#define N 200005
using namespace std;

int n,m,x;
int a[N],b[N];
map<int,int> t;
struct node{
	int x,y,id;
}used[N];
inline bool cmp(node x,node y){
	if(x.x==y.x){
		if(x.y==y.y){
			return x.id<y.id;
		}
		return x.y>y.y;
	}
	return x.x>y.x;
}
int main(){
	cin>>n;
	for(register int i=1;i<=n;i+=1){
		cin>>x;
		t[x]++;
	}
	cin>>m;
	for(register int i=1;i<=m;i+=1){
		cin>>x;
		used[x].x=t[x];
		used[x].id=i;
	}
	for(register int i=1;i<=m;i+=1){
		cin>>x;
		used[x].y=t[x];
	}
	sort(used+1,used+m+1,cmp);
	cout<<used[1].id;
	return 0;
}


#include<iostream>
#include<queue>
#include<algorithm>
using namespace std;
int n,m;
int list[600010];
int tot=0;
int sound[200010],chara[200010];
int scien[200010];
int sum[600010];
int tmp[600010];
int tot2=0;
void discrete(){
	sort(tmp+1,tmp+1+tot2);
	for(int i=1;i<=tot2;i++){
		if(i==1||tmp[i]!=tmp[i-1]){
			tot++;
			list[tot]=tmp[i];
		}
	}
}

int query(int x){
	return lower_bound(list+1,list+1+tot,x) - list;
}

int main(){
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>scien[i];
		tot2++;
		tmp[tot2]=scien[i];
	}
	int m;
	cin>>m;
	for(int i=1;i<=m;i++){
		cin>>sound[i];
		cin>>chara[i];
		tot2++;
		tmp[tot2]=sound[i];
		tot2++;
		tmp[tot2]=chara[i];
	}
	discrete();
	for(int i=1;i<=n;i++){
		sum[query(scien[i])]++;
	}
	int ans=1;
	for(int i=2;i<=m;i++){
		int h1=query(sound[i]);
		int h2=query(sound[ans]);
		if(sum[h1]>sum[h2]){

			ans=i;
		}
		else if(sum[query(sound[i])]==sum[query(sound[ans])]&&sum[query(chara[i])]>sum[query(chara[ans])]){
			ans=i;
		}
	}
	cout<<ans;
	return 0;
}


#include<bits/stdc++.h>
#define N 200009
#define in read()
using namespace std;
inline int read(){
	char ch;int f=1,res=0;
	while((ch=getchar())<'0'||ch>'9') if(ch=='-') f=-1;
	while(ch>='0'&&ch<='9'){
		res=(res<<3)+(res<<1)+ch-'0';
		ch=getchar();
	}
	return f==1?res:-res;
}
int a[N],b[N],c[N],aa[4*N];
struct node{
	int top,sec;
}p[N];
int sum[4*N],cnt=0,n,m;
int main(){
	n=in;for(int i=1;i<=n;++i) a[i]=aa[++cnt]=in;
	m=in;for(int i=1;i<=m;++i) b[i]=aa[++cnt]=in;
	for(int i=1;i<=m;++i) c[i]=aa[++cnt]=in;
	sort(aa+1,aa+cnt+1);
	int nn=n;
	nn=unique(aa+1,aa+cnt+1)-aa-1;
	for(int i=1;i<=n;++i){
		int pos=lower_bound(aa+1,aa+nn+1,a[i])-aa;
		++sum[pos];
	}
	int ans,maxn=-1,maxn2=-1;
	for(int i=1;i<=m;++i){
		int pos=lower_bound(aa+1,aa+nn+1,b[i])-aa;
		printf("%d\n",sum[pos]);
		if(sum[pos]>maxn){
			maxn=sum[pos];
			ans=i;
		}
		else if(sum[pos]==maxn){
			int pp=lower_bound(aa+1,aa+nn+1,c[i])-aa;
			if(sum[pp]>maxn2){
				maxn2=sum[pp];
				ans=i;
			}
		}
	}
	printf("%d",ans);
	return 0;
}


#include<iostream>
#include<cstdio>
#include<map>
using namespace std;

int n,m;
struct Node{
	int sheng;
	int zimu;
	int id;
}movie[ 200005 ];
int li[ 200005 ],tot=0,ans,maxy=-1,maxx=-1;

map < int , int > q;

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 main(){
	ios::sync_with_stdio(0);

	n=read();
	for( register int i = 1 ; i <= n ; i++ ){
		int x = read() ;
		q[ x ]++;
	}
	m=read();
	for( register int i = 1 ; i <= m ; i++ ){
		movie[ i ].sheng = read();
		movie[ i ].id = i;
	}
	for( register int i = 1 ; i <= m ; i++ )
		movie[ i ].zimu = read();

	for( register int i = 1 ; i <= m ; i++ )
		if(q[ movie[ i ].sheng ] > maxy ){
			tot = 0 ;
			maxy = q[ movie[ i ].sheng ];
			li[ ++tot ] = i;
		}
		else if( q[ movie[ i ].sheng ] == maxy )li[ ++tot ] = i;

	for( register int i = 1 ; i <= tot ; i++ )
		if( q[ movie[ li[ i ] ].zimu ] > maxx ){
			maxx = q[ movie[ li[ i ] ].zimu ];
			ans = i ;
		}
	cout << li[ ans ] << endl;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main(){
	cout<<1;
	return 0;
}


#include<bits/stdc++.h>
#define R register
const int N=1000000+10;
using namespace std;
map < int ,int > q1;
int c[N],b[N],cas[N],a[N];
inline int read(){
	int x = 0,f = 1;char c = getchar();
	while(!isdigit(c)){if(c == '-')f = -1;c = getchar();}
	while(isdigit(c)){x = x * 10 + c - '0';c = getchar();}
	return f * x;
}
int cmax(int x,int y){
	if(x>y)return x;
	else return y;
}
int main(){
	int n,zd=-100,ans=-1100,num=0,haha;
	cin>>n;
	for(R int i=1;i<=n;i++){
		a[i]=read();
		q1[a[i]]++;
	}
	int m;
	cin>>m;
	for(R int i=1;i<=m;i++){
		b[i]=read();
		//q2[b[i]]=q1[b[i]];
		zd=cmax(zd,q1[b[i]]);
	}
	for(R int i=1;i<=m;i++){
		if(q1[b[i]]==zd){
			cas[++num]=i;
		}
	}
	for(R int i=1;i<=m;i++){
		c[i]=read();
		//q3[c[i]]=q1[c[i]];
	}
	for(R int i=1;i<=num;i++){
		ans=cmax(ans,q1[c[cas[i]]]);
	}
	for(R int i=1;i<=num;i++){
		if(q1[c[cas[i]]]==ans){
			haha=cas[i];
			break;
		}
	}
	printf("%d",haha);
	return 0;
}


#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <iomanip>
#include <algorithm>
#include <map>
using namespace std;

const int N = 200000+10;
int listen[N], look[N];
map<int, int>mp;
int n, m;

int main()
{
	//ios::sync_with_stdio(false);
	scanf("%d", &n);
	for(int i = 1; i <= n; i++)
	{
		int x;
		scanf("%d", &x);
		mp[x]++;
	}

	scanf("%d", &m);
	for(int i = 1;i <= m; i++) scanf("%d", &listen[i]);
	for(int i = 1;i <= m; i++) scanf("%d", &look[i]);
	for(int i = 1;i <= m; i++)
	{
		listen[i] = mp[listen[i]];
		look[i] = mp[look[i]];
	}

	int cur = 1;
	for(int i = 1;i <= m; i++)
	{
		if(listen[i] > listen[cur]) cur = i;
	}
	for(int i = 1;i <= m; i++)
	{
		if(listen[i] == listen[cur] && look[i] > look[cur]) cur = i;
	}
	printf("%d\n", cur);
	return 0;
}


#include<iostream>
#include<queue>
#include<algorithm>
using namespace std;
int n,m;
priority_queue<int>q;
int list[600010];
int tot=0;
int sound[200010],chara[200010];
int scien[200010];
int sum[600010];
void discrete(){
	int last=0;
	while(!q.empty()){
		if(q.top()!=last){
			last=list[++tot]=q.top();
		}
		q.pop();
	}
}

int query(int x){
	return lower_bound(list+1,list+1+tot,x) - list;
}

int main(){
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>scien[i];
		q.push(scien[i]);
	}
	int m;
	cin>>m;
	for(int i=1;i<=m;i++){
		cin>>sound[i];
		cin>>chara[i];
		q.push(sound[i]);
		q.push(chara[i]);
	}
	discrete();
	for(int i=1;i<=n;i++){
		sum[query(scien[i])]++;
	}
	int ans=1;
	for(int i=2;i<=m;i++){
		if(sum[query(sound[i])]>sum[query(sound[ans])]){
			ans=i;
		}
		else if(sum[query(sound[i])]==sum[query(sound[ans])]&&sum[query(chara[i])]>sum[query(chara[ans])]){
			ans=i;
		}
	}
	cout<<ans;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int MAXN=200000+10;
int a[MAXN],b[MAXN],c[MAXN];
int temp[MAXN];
int N,M;
int binary_search(int x){
	int l=0,r=N;
	while(l!=r){
		int mid=(l+r)>>1;
		if(temp[mid]<x)l=mid;
		else r=mid-1;
		if(temp[r]==x&&temp[r-1]!=x)return r;
		if(temp[l]!=x&&temp[l+1]==x)return l+1;
		if(l+1==r&&temp[l]!=x&&temp[r]!=x)return MAXN-1;
	}
	return l+1;
}
int sum[MAXN];
int main(){
	scanf("%d",&N);
	for(int i=1;i<=N;i++)
	{
		scanf("%d",&a[i]);
		temp[i]=a[i];
	}
	scanf("%d",&M);
	for(int i=1;i<=M;i++)
	scanf("%d",&b[i]);
	for(int i=1;i<=M;i++)
	scanf("%d",&c[i]);
	sort(temp+1,temp+N+1);
	for(int i=1;i<=M;i++)
	{
		b[i]=binary_search(b[i]);
		c[i]=binary_search(c[i]);
	}
	for(int i=1;i<=N;i++)
	a[i]=binary_search(a[i]);
	for(int i=1;i<=N;i++)
	sum[a[i]]++;
	int u=0;
	for(int i=1;i<=M;i++)
	if(sum[b[i]]>sum[b[u]]||(sum[b[i]]>=sum[b[u]]&&sum[c[i]]>(c[u]==b[u]?0:sum[c[u]])&&c[i]!=b[i]))u=i;
	printf("%d\n",u);
	return 0;
}


#include<iostream>
#include<cstdio>
#include<string>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<algorithm>
#include<queue>
#include<vector>
#include<map>
typedef long long int ll;
const int INF = 0x7fffffff;
const int N = 2e5 + 10;
const int M = 2e5 + 10;
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int a[N+M*2];
int b[N+M*2];
int c[N+M*2];
int l1[M];
int l2[M];
int n,m;
int cnt=0;
void discreat() //离散化
{
    for(int i=1;i<=n+m*2;i++)
    {
        if(i==1||a[i]!=a[i-1])
        {
            b[++cnt]=a[i];
            c[cnt]=1;
        }
        if(i!=1&&a[i]==a[i-1])
        {
            c[cnt]++;
        }
    }
}
int query(int x) //查询x映射为那个1~cnt之间的整数
{
    return lower_bound(b+1,b+cnt+1,x)-b;
}
int main(void)
{
    IOS;
    cin>>n;
    for(int i=1;i<=n;i++)
    cin>>a[i];
    cin>>m;
    for(int i=1;i<=m;i++)
    {
        cin>>l1[i];
        a[n+i]=l1[i];
    }
    for(int i=1;i<=m;i++)
    {
        cin>>l2[i];
        a[n+m+i]=l2[i];
    }
    sort(a+1,a+m*2+n+1);
    discreat();
    int num1=0,num2=0;
    int k=0;
    for(int i=1;i<=m;i++)
    {
        int j=query(l1[i]);
        int t=query(l2[i]);
        if(c[j]>num1)
        {
            num1=c[j];
            num2=c[t];
            k=i;
        }
        else if(c[j]==num1)
        {
            if(c[t]>num2)
            {
                num2=c[t];
                k=i;
            }
        }
    }
    cout<<k<<endl;
    return 0;
}


#include<iostream>
#include<algorithm>
#define maxn 200001
using namespace std;
int tot=0,n,m,ans=1,ans1,ans2,tot2=0;;
int a[maxn],b[maxn],c[maxn],k[3*maxn],t[3*maxn],num[maxn];
void discrete()
{
	sort(k+1,k+n+1);
	for(int i=1;i<=tot;i++)
	{
		if(i==1||a[i]!=a[i-1])
		t[++tot2]=a[i];
	}
}
int query(int x)
{
	return lower_bound(k+1,k+tot2+1,x)-k;
}
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		k[++tot]=a[i];
	}
	cin>>m;
	for(int i=1;i<=m;i++)
	{
		cin>>b[i];
		k[++tot]=b[i];
	}
	for(int i=1;i<=m;i++)
	{
		cin>>c[i];
		k[++tot]=c[i];
	}
	discrete();
	for(int i=1;i<=n;i++)
	num[query(a[i])]++;
	for(int i=1;i<=m;i++)
	{
		int x1=num[query(b[i])],y1=num[query(c[i])];
		if(x1>ans1||(x1==ans1&&y1>ans2))
		{
			ans=i;
			ans1=x1;
			ans2=y1;
		}
	}
	cout<<ans<<endl;
	return 0;
}


#include <bits/stdc++.h>
#define INF 0x3f3f3f3f
using namespace std;
typedef long long ll;
inline int lowbit(int x){ return x & (-x); }
inline int read(){
    int X = 0, w = 0; char ch = 0;
    while(!isdigit(ch)) { w |= ch == '-'; ch = getchar(); }
    while(isdigit(ch)) X = (X << 3) + (X << 1) + (ch ^ 48), ch = getchar();
    return w ? -X : X;
}
inline int gcd(int a, int b){ return a % b ? gcd(b, a % b) : b; }
inline int lcm(int a, int b){ return a / gcd(a, b) * b; }
template<typename T>
inline T max(T x, T y, T z){ return max(max(x, y), z); }
template<typename T>
inline T min(T x, T y, T z){ return min(min(x, y), z); }
template<typename A, typename B, typename C>
inline A fpow(A x, B p, C yql){
    A ans = 1;
    for(; p; p >>= 1, x = 1LL * x * x % yql)if(p & 1)ans = 1LL * x * ans % yql;
    return ans;
}
const int N = 200005;
int a[N], b[N<<2], tot, num[N<<2];
struct Film{
    int x, y, cnt1, cnt2, id;
    bool operator < (const Film &rhs) const {
        if(cnt1 != rhs.cnt1) return cnt1 > rhs.cnt1;
        if(cnt2 != rhs.cnt2)cnt2 > rhs.cnt2;
        return id < rhs.id;
    }
}film[N];
int main(){

    int n = read();
    for(int i = 0; i < n; i ++) a[i] = read(), b[++tot] = a[i];
    int m = read();
    for(int i = 0; i < m; i ++){
        film[i].x = read(), film[i].y = read(), film[i].id = i;
        b[++tot] = film[i].x, b[++tot] = film[i].y;
    }
    sort(b + 1, b + tot + 1);
    tot = unique(b + 1, b + tot + 1) - b - 1;
    for(int i = 0; i < n; i ++){
        num[lower_bound(b + 1, b + tot + 1, a[i]) - b] ++;
    }
    for(int i = 0; i < m; i ++){
        film[i].cnt1 = num[lower_bound(b + 1, b + tot + 1, film[i].x) - b];
        film[i].cnt2 = num[lower_bound(b + 1, b + tot + 1, film[i].y) - b];
    }
    sort(film, film + m);
    printf("%d\n", film[0].id + 1);
    return 0;
}