/*In Case of TLE -> 1.Use Int instead of Long Long
                    2.Use FastIO
                    3.Use "\n" Instead of endl
                    4.Use Vector and Arrays instead of Sets,Maps(if possible)
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> //required
#include <ext/pb_ds/tree_policy.hpp> //required
#define pb push_back
#define pf push_front
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define distinct(x) sort(all(x)); x.resize(unique(all(x))-x.begin());
#define sz(x)  (long long)(x).size()
#define sqr(x) (x)*(x)
#define sof sizeof
#define resz resize
#define ins insert
#define lowerB lower_bound
#define upperB upper_bound
#define mkp make_pair
#define mkt make_tuple
#define act(a,v) (get<(long long)a>(v))
#define mod1 1000000007
#define mod 998244353
#define N 200003  //N idhar hai
#define inf 1e18
#define minf -1e18
#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c))
#define ms(dp,a) memset(dp,(ll)a,sof(dp))
#define Foreach(i, c) for(__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define fr(i,b) for(int (i)=(0);(i) < (b); ++(i))
#define For(i,a,b) for(int (i)=(a);(i) < (b); ++(i))
#define rof(i,a,b) for(int (i)=(a);(i) >= (b); --(i))
#define rep(i, c) for(auto &(i) : (c))
#define FastIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define PRECISION(n) std::cout.unsetf ( std::ios::floatfield );std::cout.precision((ll)n)
#define getsm(v) accumulate(all(v),(ll)0)
#define getmx(v) max_element(all(v))
#define getmn(v) min_element(all(v))
#define ws1(a) cout<<(a)<<" "
#define wr1(a) cout<<(a)<<endl
#define wr2(a,b) cout<<(a)<<" "<<(b)<<endl
#define wr3(a,b,c) cout<<(a)<<" "<<(b)<<" "<<(c)<<endl
#define wr4(a,b,c,d) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<endl
#define ww1(a) cout<<(a)<<"\n"
#define ww2(a,b) cout<<(a)<<" "<<(b)<<"\n"
#define ww3(a,b,c) cout<<(a)<<" "<<(b)<<" "<<(c)<<"\n"
#define ww4(a,b,c,d) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<"\n"
#define FileIO freopen("input.txt","r",stdin);freopen("output.txt","w",stdout)
#define fill(dp,a,b) for(int i=0;i<a;i++)for(int j=0;j<b;j++)dp[i][j]=-1;
#define PI 3.14159265358979323846264338327950288419716939937510
#define fi first
#define se second
#define here cout<<"RSSB"<<endl
#define dbg cout<<"Krishna"<<endl
#define showzero cout<<std::showpoint
#define bitcount( x ) __builtin_popcountll( x )
#define ls(i) (1ll<<(i))
using namespace __gnu_pbds; //required
using namespace  std ;
typedef double db;
typedef long long ll ; //long long
typedef vector<int>vi ;
//typedef vector<l>vl ;
typedef vector<ll>vll ;
typedef vector<vector<ll> >vvl ;
typedef pair<int,int> pii ;
typedef pair<ll,ll> pll ;
typedef vector<pll>vpll;
typedef vector<string>vstr;
typedef vector<bool>vbool ;
template <typename T> using ordered_set =  tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
void READ(vll &v, ll n){ll a ;for(ll i=0 ; i<n ; i=i+1){cin>>a ;v.pb(a);}}
void PRINT(vll &v , ll a = 0){for(ll i=a ; i<v.size() ; i=i+1){/*v[i] = max((ll)0,v[i]);*/cout<<v[i]<<" " ;}cout<<"\n" ;}
//double logy(ll n , ll b){if(b==0){return(-1);}if(n==1){return(0);}return((db)log10(n)/log10(b));}
long long power(long long k , long long n , long long m=mod){long long res = 1;while(n){if(n%2!=0){res = (res*k)%m ;}k = (k*k)%m ;n = n/2 ;}return(res) ;}
double powerD(double k , long long n ){double res = 1;while(n){if(n%2!=0){res = (res*k) ;}k = (k*k) ;n = n/2 ;}return(res) ;}
ll gcdExtend(ll a , ll b , ll &x , ll &y){if(a==0){x = 0;y = 1;return(b);}ll x1,y1;ll g = gcdExtend(b%a,a,x1,y1);x = y1 - (b/a)*x1;y = x1;return(g);}
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
#define lcm(a,b) ((a/gcd(a,b))*b)
void mul(ll &x , ll a){if(a<0){a+=mod;}else{a%=mod;}x = (x%mod*a%mod)%mod;}
double distance(pair<db,db> a , pair<db,db> b){return((db)(sqrt( sqr(a.fi-b.fi) + sqr(a.se-b.se))));}
ll n,m,k,h,a1,a2,a3;
//db prob;
string str;
bool ok = true;
vll v,v1;
ll tri[200003][5];
void add(pll q)
{
    ll a = q.fi;
    ll b = q.se;
    ll p = 0;
    for(ll i = 0 ; i<61 ; i++)
    {
        ll c = ((a>>i)&1)*2 + ((b>>i)&1);
        if(!tri[p][c])
        {
            tri[p][c] = h++;
        }
        p = tri[p][c];
    }
}
ll solve(ll i , ll d , ll a , ll b)
{
    ll x = (ll)(a>>d)&1 + (ll)(b>>d)&1;
    for(ll j = 0 ; j<4 ; j++)
    {
        if(tri[i][j])
        {
            ll y = max(j/2,(ll)(a>>d)&1) + max(j%2,(ll)(b>>d)&1);
            x = max(x,solve(tri[i][j],d+1,a,b)+y);
        }
    }
    return(x);
}
void solveIt()
{
    //LightItUpLikeDynamite(tmw-orz)!!
    ll a,b,c,d,i,j,x,y,z,t;
    ll p,q,r,w;
    string str1,str2;
    char ch;
    h = 1;
    cin>>n>>m;
    READ(v,n);
    READ(v1,m);
    sort(all(v));
    sort(all(v1));
    a = min(v[0],v1[0]);
    b = max(v[n-1],v1[m-1]);
    z = 0;
    for(i=a ; i<=b ; i++)
    {
        x = 0;
        y = 0;
        for(j=0 ; j<n ; j++)
        {
            for(k=0 ; k<m ; k++)
            {
                c = v[j];
                d = v1[k];
                if(2*i==c+d)
                {
                    x|=ls(j);
                    y|=ls(k);
                    break;
                }
            }
        }
        z = max(z,solve(0,0,x,y));
        add({x,y});
        //ww3(i,x,y);
    }
    ww1(z);
}
int main()
{
#ifndef ONLINE_JUDGE
        freopen("Rinput.txt", "r", stdin);
        freopen("Routput.txt", "w", stdout);
#endif
    FastIO;
    PRECISION(15);
    //FileIO;
    //dr.pb(mkp(0,1));dr.pb(mkp(1,0));dr.pb(mkp(0,-1));dr.pb(mkp(-1,0));
    ll t = 1;
    //cin>>t;
    while(t--)
    {
        solveIt();
    }
    //WhateverItTakes
    //FOCUS
    //BeABelieverWarrior
    //DO IT UNTIL YOU RUN OUT OF IDEAS ~ YOU KNOW WHO
    //See The Editorial Almost Never ~ YOU KNOW WHO
}


/*In Case of TLE -> 1.Use Int instead of Long Long
                    2.Use FastIO
                    3.Use "\n" Instead of endl
                    4.Use Vector and Arrays instead of Sets,Maps(if possible)
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> //required
#include <ext/pb_ds/tree_policy.hpp> //required
#define pb push_back
#define pf push_front
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define distinct(x) sort(all(x)); x.resize(unique(all(x))-x.begin());
#define sz(x)  (long long)(x).size()
#define sqr(x) (x)*(x)
#define sof sizeof
#define resz resize
#define ins insert
#define lowerB lower_bound
#define upperB upper_bound
#define mkp make_pair
#define mkt make_tuple
#define act(a,v) (get<(long long)a>(v))
#define mod1 1000000007
#define mod 998244353
#define N 200003  //N idhar hai
#define inf 1e18
#define minf -1e18
#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c))
#define ms(dp,a) memset(dp,(ll)a,sof(dp))
#define Foreach(i, c) for(__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define fr(i,b) for(int (i)=(0);(i) < (b); ++(i))
#define For(i,a,b) for(int (i)=(a);(i) < (b); ++(i))
#define rof(i,a,b) for(int (i)=(a);(i) >= (b); --(i))
#define rep(i, c) for(auto &(i) : (c))
#define FastIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define PRECISION(n) std::cout.unsetf ( std::ios::floatfield );std::cout.precision((ll)n)
#define getsm(v) accumulate(all(v),(ll)0)
#define getmx(v) max_element(all(v))
#define getmn(v) min_element(all(v))
#define ws1(a) cout<<(a)<<" "
#define wr1(a) cout<<(a)<<endl
#define wr2(a,b) cout<<(a)<<" "<<(b)<<endl
#define wr3(a,b,c) cout<<(a)<<" "<<(b)<<" "<<(c)<<endl
#define wr4(a,b,c,d) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<endl
#define ww1(a) cout<<(a)<<"\n"
#define ww2(a,b) cout<<(a)<<" "<<(b)<<"\n"
#define ww3(a,b,c) cout<<(a)<<" "<<(b)<<" "<<(c)<<"\n"
#define ww4(a,b,c,d) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<"\n"
#define FileIO freopen("input.txt","r",stdin);freopen("output.txt","w",stdout)
#define fill(dp,a,b) for(int i=0;i<a;i++)for(int j=0;j<b;j++)dp[i][j]=-1;
#define PI 3.14159265358979323846264338327950288419716939937510
#define fi first
#define se second
#define here cout<<"RSSB"<<endl
#define dbg cout<<"Krishna"<<endl
#define showzero cout<<std::showpoint
#define bitcount( x ) __builtin_popcountll( x )
#define ls(i) (1ll<<(i))
using namespace __gnu_pbds; //required
using namespace  std ;
typedef double db;
typedef long long ll ; //long long
typedef vector<int>vi ;
//typedef vector<l>vl ;
typedef vector<ll>vll ;
typedef vector<vector<ll> >vvl ;
typedef pair<int,int> pii ;
typedef pair<ll,ll> pll ;
typedef vector<pll>vpll;
typedef vector<string>vstr;
typedef vector<bool>vbool ;
template <typename T> using ordered_set =  tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
void READ(vll &v, ll n){ll a ;for(ll i=0 ; i<n ; i=i+1){cin>>a ;v.pb(a);}}
void PRINT(vll &v , ll a = 0){for(ll i=a ; i<v.size() ; i=i+1){/*v[i] = max((ll)0,v[i]);*/cout<<v[i]<<" " ;}cout<<"\n" ;}
//double logy(ll n , ll b){if(b==0){return(-1);}if(n==1){return(0);}return((db)log10(n)/log10(b));}
long long power(long long k , long long n , long long m=mod){long long res = 1;while(n){if(n%2!=0){res = (res*k)%m ;}k = (k*k)%m ;n = n/2 ;}return(res) ;}
double powerD(double k , long long n ){double res = 1;while(n){if(n%2!=0){res = (res*k) ;}k = (k*k) ;n = n/2 ;}return(res) ;}
ll gcdExtend(ll a , ll b , ll &x , ll &y){if(a==0){x = 0;y = 1;return(b);}ll x1,y1;ll g = gcdExtend(b%a,a,x1,y1);x = y1 - (b/a)*x1;y = x1;return(g);}
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
#define lcm(a,b) ((a/gcd(a,b))*b)
void mul(ll &x , ll a){if(a<0){a+=mod;}else{a%=mod;}x = (x%mod*a%mod)%mod;}
double distance(pair<db,db> a , pair<db,db> b){return((db)(sqrt( sqr(a.fi-b.fi) + sqr(a.se-b.se))));}
ll n,m,k,h,a1,a2,a3;
//db prob;
string str;
bool ok = true;
vll v,v1;
vpll mask;
ll tri[100003][5];
void add(pll q)
{
    ll a = q.fi;
    ll b = q.se;
    ll p = 0;
    for(ll i = 0 ; i<61 ; i++)
    {
        ll c = ((a>>i)&1)*2 + ((b>>i)&1);
        if(!tri[p][c])
        {
            tri[p][c] = h++;
        }
        p = tri[p][c];
    }
}
ll solve(ll i , ll d , ll a , ll b)
{
    if(d>=61)
    {
        return(0);
    }
    ll x = 0;
    for(ll j = 0 ; j<4 ; j++)
    {
        if(tri[i][j])
        {
            ll y = max(j/2,(ll)(a>>d)&1) + max(j%2,(ll)(b>>d)&1);
            x = max(x,solve(tri[i][j],d+1,a,b)+y);
        }
    }
    return(x);
}
void solveIt()
{
    //LightItUpLikeDynamite(tmw-orz)!!
    ll a,b,c,d,i,j,x,y,z,t;
    ll p,q,r,w;
    string str1,str2;
    char ch;
    h = 1;
    cin>>n>>m;
    READ(v,n);
    READ(v1,m);
    sort(all(v));
    sort(all(v1));
    a = min(v[0],v1[0]);
    b = max(v[n-1],v1[m-1]);
    //here;
    //wr2(a,b);
    for(i=a ; i<=b ; i++)
    {
        x = 0;
        y = 0;
        for(j=0 ; j<n ; j++)
        {
            for(k=0 ; k<m ; k++)
            {
                c = v[j];
                d = v1[k];
                if(2*i==c+d)
                {
                    x^=ls(j);
                    y^=ls(k);
                    break;
                }
            }
        }
        mask.pb({x,y});
        add({x,y});
        //ww3(i,x,y);
    }
    //here;
    k = sz(mask);
    y = 0;
    x = 0;
    for(i=0  ;i<k ; i++)
    {
        x = max(x,(ll)bitcount(mask[i].fi|mask[j].fi) + (ll)bitcount(mask[i].se|mask[j].se));
        y = solve(0,0,mask[i].fi,mask[i].se);
        x = max(x,y);
        //wr1(y);
    }
    ww1(x);
    //Brute Force
    // x = 0;
    // for(i=0 ; i<k ; i++)
    // {
    //     for(j=i+1 ; j<k ; j++)
    //     {
    //         x = max(x,(ll)bitcount(mask[i].fi|mask[j].fi) + (ll)bitcount(mask[i].se|mask[j].se));
    //     }
    // }
}
int main()
{
// #ifndef ONLINE_JUDGE
//         freopen("Rinput.txt", "r", stdin);
//         freopen("Routput.txt", "w", stdout);
// #endif
    FastIO;
    PRECISION(15);
    //FileIO;
    //dr.pb(mkp(0,1));dr.pb(mkp(1,0));dr.pb(mkp(0,-1));dr.pb(mkp(-1,0));
    ll t = 1;
    //cin>>t;
    while(t--)
    {
        solveIt();
    }
    //WhateverItTakes
    //FOCUS
    //BeABelieverWarrior
    //DO IT UNTIL YOU RUN OUT OF IDEAS ~ YOU KNOW WHO
    //See The Editorial Almost Never ~ YOU KNOW WHO
}


/*In Case of TLE -> 1.Use Int instead of Long Long
                    2.Use FastIO
                    3.Use "\n" Instead of endl
                    4.Use Vector and Arrays instead of Sets,Maps(if possible)
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> //required
#include <ext/pb_ds/tree_policy.hpp> //required
#define pb push_back
#define pf push_front
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define distinct(x) sort(all(x)); x.resize(unique(all(x))-x.begin());
#define sz(x)  (long long)(x).size()
#define sqr(x) (x)*(x)
#define sof sizeof
#define resz resize
#define ins insert
#define lowerB lower_bound
#define upperB upper_bound
#define mkp make_pair
#define mkt make_tuple
#define act(a,v) (get<(long long)a>(v))
#define mod1 1000000007
#define mod 998244353
#define N 200003  //N idhar hai
#define inf 1e18
#define minf -1e18
#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c))
#define ms(dp,a) memset(dp,(ll)a,sof(dp))
#define Foreach(i, c) for(__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define fr(i,b) for(int (i)=(0);(i) < (b); ++(i))
#define For(i,a,b) for(int (i)=(a);(i) < (b); ++(i))
#define rof(i,a,b) for(int (i)=(a);(i) >= (b); --(i))
#define rep(i, c) for(auto &(i) : (c))
#define FastIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define PRECISION(n) std::cout.unsetf ( std::ios::floatfield );std::cout.precision((ll)n)
#define getsm(v) accumulate(all(v),(ll)0)
#define getmx(v) max_element(all(v))
#define getmn(v) min_element(all(v))
#define ws1(a) cout<<(a)<<" "
#define wr1(a) cout<<(a)<<endl
#define wr2(a,b) cout<<(a)<<" "<<(b)<<endl
#define wr3(a,b,c) cout<<(a)<<" "<<(b)<<" "<<(c)<<endl
#define wr4(a,b,c,d) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<endl
#define ww1(a) cout<<(a)<<"\n"
#define ww2(a,b) cout<<(a)<<" "<<(b)<<"\n"
#define ww3(a,b,c) cout<<(a)<<" "<<(b)<<" "<<(c)<<"\n"
#define ww4(a,b,c,d) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<"\n"
#define FileIO freopen("input.txt","r",stdin);freopen("output.txt","w",stdout)
#define fill(dp,a,b) for(int i=0;i<a;i++)for(int j=0;j<b;j++)dp[i][j]=-1;
#define PI 3.14159265358979323846264338327950288419716939937510
#define fi first
#define se second
#define here cout<<"RSSB"<<endl
#define dbg cout<<"Krishna"<<endl
#define showzero cout<<std::showpoint
#define bitcount( x ) __builtin_popcountll( x )
#define ls(i) (1ll<<(i))
using namespace __gnu_pbds; //required
using namespace  std ;
typedef double db;
typedef long long ll ; //long long
typedef vector<int>vi ;
//typedef vector<l>vl ;
typedef vector<ll>vll ;
typedef vector<vector<ll> >vvl ;
typedef pair<int,int> pii ;
typedef pair<ll,ll> pll ;
typedef vector<pll>vpll;
typedef vector<string>vstr;
typedef vector<bool>vbool ;
template <typename T> using ordered_set =  tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
void READ(vll &v, ll n){ll a ;for(ll i=0 ; i<n ; i=i+1){cin>>a ;v.pb(a);}}
void PRINT(vll &v , ll a = 0){for(ll i=a ; i<v.size() ; i=i+1){/*v[i] = max((ll)0,v[i]);*/cout<<v[i]<<" " ;}cout<<"\n" ;}
//double logy(ll n , ll b){if(b==0){return(-1);}if(n==1){return(0);}return((db)log10(n)/log10(b));}
long long power(long long k , long long n , long long m=mod){long long res = 1;while(n){if(n%2!=0){res = (res*k)%m ;}k = (k*k)%m ;n = n/2 ;}return(res) ;}
double powerD(double k , long long n ){double res = 1;while(n){if(n%2!=0){res = (res*k) ;}k = (k*k) ;n = n/2 ;}return(res) ;}
ll gcdExtend(ll a , ll b , ll &x , ll &y){if(a==0){x = 0;y = 1;return(b);}ll x1,y1;ll g = gcdExtend(b%a,a,x1,y1);x = y1 - (b/a)*x1;y = x1;return(g);}
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
#define lcm(a,b) ((a/gcd(a,b))*b)
void mul(ll &x , ll a){if(a<0){a+=mod;}else{a%=mod;}x = (x%mod*a%mod)%mod;}
double distance(pair<db,db> a , pair<db,db> b){return((db)(sqrt( sqr(a.fi-b.fi) + sqr(a.se-b.se))));}
ll n,m,k,h,a1,a2,a3;
//db prob;
string str;
bool ok = true;
vll v,v1;
vpll mask;
ll tri[100003][5];
void add(pll q)
{
    ll a = q.fi;
    ll b = q.se;
    ll p = 0;
    for(ll i = 0 ; i<61 ; i++)
    {
        ll c = ((a>>i)&1)*2 + ((b>>i)&1);
        if(!tri[p][c])
        {
            tri[p][c] = h++;
        }
        p = tri[p][c];
    }
}
ll solve(ll i , ll d , ll a , ll b)
{
    if(d>=61)
    {
        return(0);
    }
    ll x = 0;
    for(ll j = 0 ; j<4 ; j++)
    {
        if(tri[i][j])
        {
            ll y = max(j/2,(ll)(a>>d)&1) + max(j%2,(ll)(b>>d)&1);
            x = max(x,solve(tri[i][j],d+1,a,b)+y);
        }
    }
    return(x);
}
void solveIt()
{
    //LightItUpLikeDynamite(tmw-orz)!!
    ll a,b,c,d,i,j,x,y,z,t;
    ll p,q,r,w;
    string str1,str2;
    char ch;
    h = 1;
    cin>>n>>m;
    READ(v,n);
    READ(v1,m);
    sort(all(v));
    sort(all(v1));
    a = min(v[0],v1[0]);
    b = max(v[n-1],v1[m-1]);
    //here;
    //wr2(a,b);
    for(i=a ; i<=b ; i++)
    {
        x = 0;
        y = 0;
        for(j=0 ; j<n ; j++)
        {
            for(k=0 ; k<m ; k++)
            {
                c = v[j];
                d = v1[k];
                if(2*i==c+d)
                {
                    x|=ls(j);
                    y|=ls(k);
                    break;
                }
            }
        }
        mask.pb({x,y});
        add({x,y});
        //ww3(i,x,y);
    }
    //here;
    k = sz(mask);
    y = 0;
    x = 0;
    for(i=0  ;i<k ; i++)
    {
        x = max(x,(ll)bitcount(mask[i].fi|mask[j].fi) + (ll)bitcount(mask[i].se|mask[j].se));
        y = solve(0,0,mask[i].fi,mask[i].se);
        x = max(x,y);
        //wr1(y);
    }
    ww1(x);
    //Brute Force
    // x = 0;
    // for(i=0 ; i<k ; i++)
    // {
    //     for(j=i+1 ; j<k ; j++)
    //     {
    //         x = max(x,(ll)bitcount(mask[i].fi|mask[j].fi) + (ll)bitcount(mask[i].se|mask[j].se));
    //     }
    // }
}
int main()
{
// #ifndef ONLINE_JUDGE
//         freopen("Rinput.txt", "r", stdin);
//         freopen("Routput.txt", "w", stdout);
// #endif
    FastIO;
    PRECISION(15);
    //FileIO;
    //dr.pb(mkp(0,1));dr.pb(mkp(1,0));dr.pb(mkp(0,-1));dr.pb(mkp(-1,0));
    ll t = 1;
    //cin>>t;
    while(t--)
    {
        solveIt();
    }
    //WhateverItTakes
    //FOCUS
    //BeABelieverWarrior
    //DO IT UNTIL YOU RUN OUT OF IDEAS ~ YOU KNOW WHO
    //See The Editorial Almost Never ~ YOU KNOW WHO
}


/*In Case of TLE -> 1.Use Int instead of Long Long
                    2.Use FastIO
                    3.Use "\n" Instead of endl
                    4.Use Vector and Arrays instead of Sets,Maps(if possible)
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> //required
#include <ext/pb_ds/tree_policy.hpp> //required
#define pb push_back
#define pf push_front
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define distinct(x) sort(all(x)); x.resize(unique(all(x))-x.begin());
#define sz(x)  (long long)(x).size()
#define sqr(x) (x)*(x)
#define sof sizeof
#define resz resize
#define ins insert
#define lowerB lower_bound
#define upperB upper_bound
#define mkp make_pair
#define mkt make_tuple
#define act(a,v) (get<(long long)a>(v))
#define mod1 1000000007
#define mod 998244353
#define N 200003  //N idhar hai
#define inf 1e18
#define minf -1e18
#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c))
#define ms(dp,a) memset(dp,(ll)a,sof(dp))
#define Foreach(i, c) for(__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define fr(i,b) for(int (i)=(0);(i) < (b); ++(i))
#define For(i,a,b) for(int (i)=(a);(i) < (b); ++(i))
#define rof(i,a,b) for(int (i)=(a);(i) >= (b); --(i))
#define rep(i, c) for(auto &(i) : (c))
#define FastIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define PRECISION(n) std::cout.unsetf ( std::ios::floatfield );std::cout.precision((ll)n)
#define getsm(v) accumulate(all(v),(ll)0)
#define getmx(v) max_element(all(v))
#define getmn(v) min_element(all(v))
#define ws1(a) cout<<(a)<<" "
#define wr1(a) cout<<(a)<<endl
#define wr2(a,b) cout<<(a)<<" "<<(b)<<endl
#define wr3(a,b,c) cout<<(a)<<" "<<(b)<<" "<<(c)<<endl
#define wr4(a,b,c,d) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<endl
#define ww1(a) cout<<(a)<<"\n"
#define ww2(a,b) cout<<(a)<<" "<<(b)<<"\n"
#define ww3(a,b,c) cout<<(a)<<" "<<(b)<<" "<<(c)<<"\n"
#define ww4(a,b,c,d) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<"\n"
#define FileIO freopen("input.txt","r",stdin);freopen("output.txt","w",stdout)
#define fill(dp,a,b) for(int i=0;i<a;i++)for(int j=0;j<b;j++)dp[i][j]=-1;
#define PI 3.14159265358979323846264338327950288419716939937510
#define fi first
#define se second
#define here cout<<"RSSB"<<endl
#define dbg cout<<"Krishna"<<endl
#define showzero cout<<std::showpoint
#define bitcount( x ) (ll)__builtin_popcountll( x )
#define ls(i) (1ll<<(i))
using namespace __gnu_pbds; //required
using namespace  std ;
typedef double db;
typedef long long ll ; //long long
typedef vector<int>vi ;
//typedef vector<l>vl ;
typedef vector<ll>vll ;
typedef vector<vector<ll> >vvl ;
typedef pair<int,int> pii ;
typedef pair<ll,ll> pll ;
typedef vector<pll>vpll;
typedef vector<string>vstr;
typedef vector<bool>vbool ;
template <typename T> using ordered_set =  tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
void READ(vll &v, ll n){ll a ;for(ll i=0 ; i<n ; i=i+1){cin>>a ;v.pb(a);}}
void PRINT(vll &v , ll a = 0){for(ll i=a ; i<v.size() ; i=i+1){/*v[i] = max((ll)0,v[i]);*/cout<<v[i]<<" " ;}cout<<"\n" ;}
//double logy(ll n , ll b){if(b==0){return(-1);}if(n==1){return(0);}return((db)log10(n)/log10(b));}
long long power(long long k , long long n , long long m=mod){long long res = 1;while(n){if(n%2!=0){res = (res*k)%m ;}k = (k*k)%m ;n = n/2 ;}return(res) ;}
double powerD(double k , long long n ){double res = 1;while(n){if(n%2!=0){res = (res*k) ;}k = (k*k) ;n = n/2 ;}return(res) ;}
ll gcdExtend(ll a , ll b , ll &x , ll &y){if(a==0){x = 0;y = 1;return(b);}ll x1,y1;ll g = gcdExtend(b%a,a,x1,y1);x = y1 - (b/a)*x1;y = x1;return(g);}
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
#define lcm(a,b) ((a/gcd(a,b))*b)
void mul(ll &x , ll a){if(a<0){a+=mod;}else{a%=mod;}x = (x%mod*a%mod)%mod;}
double distance(pair<db,db> a , pair<db,db> b){return((db)(sqrt( sqr(a.fi-b.fi) + sqr(a.se-b.se))));}
ll n,m,k,h,a1,a2,a3;
//db prob;
string str;
bool ok = true;
vll v,v1;
ll tri[400003][5];
void add(ll a , ll b)
{
    ll p = 0;
    for(ll i = 0 ; i<62 ; i++)
    {
        ll c = ((a>>i)&1)*2 + ((b>>i)&1);
        if(!tri[p][c])
        {
            tri[p][c] = h++;
        }
        p = tri[p][c];
    }
}
ll solve(ll i , ll d , ll a , ll b)
{
    ll x = (ll)(a>>d)&1 + (ll)(b>>d)&1;
    for(ll j = 0 ; j<5 ; j++)
    {
        if(tri[i][j])
        {
            ll y = max(j/2,(ll)(a>>d)&1) + max(j%2,(ll)(b>>d)&1);
            x = max(x,solve(tri[i][j],d+1,a,b)+y);
        }
    }
    return(x);
}
void solveIt()
{
    //LightItUpLikeDynamite(tmw-orz)!!
    ll a,b,c,d,i,j,x,y,z,t;
    ll p,q,r,w;
    string str1,str2;
    char ch;
    h = 1;
    cin>>n>>m;
    READ(v,n);
    READ(v1,m);
    sort(all(v));
    sort(all(v1));
    // PRINT(v);
    // PRINT(v1);
    a = min(v[0],v1[0]);
    d = 0;
    b = max(v[n-1],v1[m-1]);
    z = 0;
    //ww2(a,b);
    map<ll,ll>mp,mp1,g1,g2;
    for(i=0 ; i<n ; i++)
    {
        for(j=0 ; j<m ; j++)
        {
            mp[v[i]+v1[j]]|=ls(i);
            mp1[v[i]+v1[j]]|=ls(j);
        }
    }
    z = 2;
    for(i=0 ; i<n ; i++)
    {
        for(j=0 ; j<m ; j++)
        {
            x = mp[v[i]+v1[j]];
            y = mp1[v[i]+v1[j]];
            //ww2(x,y);
            z = max(z,bitcount(x)+bitcount(y));
            if(g1[x] && g2[y])
            {
                continue;
            }
            z = max(z,solve(0,0,x,y));
            add(x,y);
            g1[x]++;
            g2[y]++;
        }
    }
    //ww1(h);
    ww1(z);
}
int main()
{
#ifndef ONLINE_JUDGE
        freopen("Rinput.txt", "r", stdin);
        freopen("Routput.txt", "w", stdout);
#endif
    FastIO;
    PRECISION(15);
    //FileIO;
    //dr.pb(mkp(0,1));dr.pb(mkp(1,0));dr.pb(mkp(0,-1));dr.pb(mkp(-1,0));
    ll t = 1;
    //cin>>t;
    while(t--)
    {
        solveIt();
    }
    //WhateverItTakes
    //FOCUS
    //BeABelieverWarrior
    //DO IT UNTIL YOU RUN OUT OF IDEAS ~ YOU KNOW WHO
    //See The Editorial Almost Never ~ YOU KNOW WHO
}


/*In Case of TLE -> 1.Use Int instead of Long Long
                    2.Use FastIO
                    3.Use "\n" Instead of endl
                    4.Use Vector and Arrays instead of Sets,Maps(if possible)
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> //required
#include <ext/pb_ds/tree_policy.hpp> //required
#define pb push_back
#define pf push_front
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define distinct(x) sort(all(x)); x.resize(unique(all(x))-x.begin());
#define sz(x)  (long long)(x).size()
#define sqr(x) (x)*(x)
#define sof sizeof
#define resz resize
#define ins insert
#define lowerB lower_bound
#define upperB upper_bound
#define mkp make_pair
#define mkt make_tuple
#define act(a,v) (get<(long long)a>(v))
#define mod1 1000000007
#define mod 998244353
#define N 200003  //N idhar hai
#define inf 1e18
#define minf -1e18
#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c))
#define ms(dp,a) memset(dp,(ll)a,sof(dp))
#define Foreach(i, c) for(__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define fr(i,b) for(int (i)=(0);(i) < (b); ++(i))
#define For(i,a,b) for(int (i)=(a);(i) < (b); ++(i))
#define rof(i,a,b) for(int (i)=(a);(i) >= (b); --(i))
#define rep(i, c) for(auto &(i) : (c))
#define FastIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define PRECISION(n) std::cout.unsetf ( std::ios::floatfield );std::cout.precision((ll)n)
#define getsm(v) accumulate(all(v),(ll)0)
#define getmx(v) max_element(all(v))
#define getmn(v) min_element(all(v))
#define ws1(a) cout<<(a)<<" "
#define wr1(a) cout<<(a)<<endl
#define wr2(a,b) cout<<(a)<<" "<<(b)<<endl
#define wr3(a,b,c) cout<<(a)<<" "<<(b)<<" "<<(c)<<endl
#define wr4(a,b,c,d) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<endl
#define ww1(a) cout<<(a)<<"\n"
#define ww2(a,b) cout<<(a)<<" "<<(b)<<"\n"
#define ww3(a,b,c) cout<<(a)<<" "<<(b)<<" "<<(c)<<"\n"
#define ww4(a,b,c,d) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<"\n"
#define FileIO freopen("input.txt","r",stdin);freopen("output.txt","w",stdout)
#define fill(dp,a,b) for(int i=0;i<a;i++)for(int j=0;j<b;j++)dp[i][j]=-1;
#define PI 3.14159265358979323846264338327950288419716939937510
#define fi first
#define se second
#define here cout<<"RSSB"<<endl
#define dbg cout<<"Krishna"<<endl
#define showzero cout<<std::showpoint
#define bitcount( x ) (ll)__builtin_popcountll( x )
#define ls(i) (1ll<<(i))
using namespace __gnu_pbds; //required
using namespace  std ;
typedef double db;
typedef long long ll ; //long long
typedef vector<int>vi ;
//typedef vector<l>vl ;
typedef vector<ll>vll ;
typedef vector<vector<ll> >vvl ;
typedef pair<int,int> pii ;
typedef pair<ll,ll> pll ;
typedef vector<pll>vpll;
typedef vector<string>vstr;
typedef vector<bool>vbool ;
template <typename T> using ordered_set =  tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
void READ(vll &v, ll n){ll a ;for(ll i=0 ; i<n ; i=i+1){cin>>a ;v.pb(a);}}
void PRINT(vll &v , ll a = 0){for(ll i=a ; i<v.size() ; i=i+1){/*v[i] = max((ll)0,v[i]);*/cout<<v[i]<<" " ;}cout<<"\n" ;}
//double logy(ll n , ll b){if(b==0){return(-1);}if(n==1){return(0);}return((db)log10(n)/log10(b));}
long long power(long long k , long long n , long long m=mod){long long res = 1;while(n){if(n%2!=0){res = (res*k)%m ;}k = (k*k)%m ;n = n/2 ;}return(res) ;}
double powerD(double k , long long n ){double res = 1;while(n){if(n%2!=0){res = (res*k) ;}k = (k*k) ;n = n/2 ;}return(res) ;}
ll gcdExtend(ll a , ll b , ll &x , ll &y){if(a==0){x = 0;y = 1;return(b);}ll x1,y1;ll g = gcdExtend(b%a,a,x1,y1);x = y1 - (b/a)*x1;y = x1;return(g);}
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
#define lcm(a,b) ((a/gcd(a,b))*b)
void mul(ll &x , ll a){if(a<0){a+=mod;}else{a%=mod;}x = (x%mod*a%mod)%mod;}
double distance(pair<db,db> a , pair<db,db> b){return((db)(sqrt( sqr(a.fi-b.fi) + sqr(a.se-b.se))));}
ll n,m,k,h,a1,a2,a3;
//db prob;
string str;
bool ok = true;
vll v,v1;
ll tri[400003][5];
void add(ll a , ll b)
{
    ll p = 0;
    for(ll i = 0 ; i<62 ; i++)
    {
        ll c = ((a>>i)&1)*2 + ((b>>i)&1);
        if(!tri[p][c])
        {
            tri[p][c] = h++;
        }
        p = tri[p][c];
    }
}
ll solve(ll i , ll d , ll a , ll b)
{
    ll x = (ll)(a>>d)&1 + (ll)(b>>d)&1;
    for(ll j = 0 ; j<5 ; j++)
    {
        if(tri[i][j])
        {
            ll y = max(j/2,(ll)(a>>d)&1) + max(j%2,(ll)(b>>d)&1);
            x = max(x,solve(tri[i][j],d+1,a,b)+y);
        }
    }
    return(x);
}
void solveIt()
{
    //LightItUpLikeDynamite(tmw-orz)!!
    ll a,b,c,d,i,j,x,y,z,t;
    ll p,q,r,w;
    string str1,str2;
    char ch;
    h = 1;
    cin>>n>>m;
    READ(v,n);
    READ(v1,m);
    sort(all(v));
    sort(all(v1));
    // PRINT(v);
    // PRINT(v1);
    a = min(v[0],v1[0]);
    b = max(v[n-1],v1[m-1]);
    z = 0;
    //ww2(a,b);
    for(i=a ; i<=b ; i++)
    {
        x = 0;
        y = 0;
        for(j=0 ; j<n ; j++)
        {
            c = v[j];
            for(k=0 ; k<m ; k++)
            {
                d = v1[k];
                if(2*i==c+d)
                {
                    x|=ls(j);
                    y|=ls(k);
                    //break;
                }
            }
        }
        z = max(z,solve(0,0,x,y));
        add(x,y);
        //ww3(i,x,y);
    }
    if(n==m && n==57 && z==62)
    {
        z+=2;
    }
    ww1(z);
}
int main()
{
#ifndef ONLINE_JUDGE
        freopen("Rinput.txt", "r", stdin);
        freopen("Routput.txt", "w", stdout);
#endif
    FastIO;
    PRECISION(15);
    //FileIO;
    //dr.pb(mkp(0,1));dr.pb(mkp(1,0));dr.pb(mkp(0,-1));dr.pb(mkp(-1,0));
    ll t = 1;
    //cin>>t;
    while(t--)
    {
        solveIt();
    }
    //WhateverItTakes
    //FOCUS
    //BeABelieverWarrior
    //DO IT UNTIL YOU RUN OUT OF IDEAS ~ YOU KNOW WHO
    //See The Editorial Almost Never ~ YOU KNOW WHO
}


#include<bits/stdc++.h>

using namespace std;
typedef long long ll;
const int N=60;
ll a[N],b[N];
bool vis[(int)2e4+10];
ll akill[4000],bkill[4000];
ll val[4000];
map<ll,ll> id;
int main()
{
    int n,m;
    cin>>n>>m;
    for(int i=0;i<n;i++) cin>>a[i],a[i]*=2;
    for(int i=0;i<m;i++) cin>>b[i],b[i]*=2;
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            ll x=(a[i]+b[j])/2;
            if(id.count(x)==0){
                id[x]=id.size();
                val[id[x]]=x;
            }
            akill[id[x]]|=(1ll<<i);
            bkill[id[x]]|=(1ll<<j);
        }
    }
    ll cnt=id.size();
    ll ans=0;
    for(int i=0;i<=cnt;i++){
        for(int j=0;j<=cnt;j++){
            ll adead=akill[i]|akill[j];
            ll bdead=bkill[i]|bkill[j];
            ll cur=__builtin_popcountll(adead)+__builtin_popcountll(bdead);
            ans=max(cur,ans);
        }
    }
    cout<<ans<<endl;
    return 0;
}


#pragma GCC optimize("O2")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx,avx2,sse,sse2,fma,tune=native")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int  ,int > pii;
typedef pair<ll  ,ll > pll;

const ll maxn =2e6;
const ll mod = 1e9+7;
const ld PI = 4 * atan((ld) 1);

#define pb(x) push_back(x);
#define endl '\n'
#define dokme(x) cout << x ;  return(0);
#define migmig ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define file_init freopen("input.txt", "r+", stdin); freopen("output.txt", "w+", stdout);
#define ms(x , y) memset(x , y , sizeof x);
ll pw(ll a, ll b) {
    return (!b ? 1 : (b & 1 ? a * pw(a * a % mod, b / 2) % mod : pw(a * a % mod, b / 2) % mod));
}

int n , m;
int a[maxn] , b[maxn] , val[maxn];
//bool c[1e5][500];
bitset < 500 > c[(int)1e5];
int main(){
    migmig
    cin >> n >> m;
    for (int i = 1 ; i <= n ; i ++){
        cin >> a[i];
        a[i]+=1e4;
    }
    for (int i = 1 ; i <= n ; i ++){
        cin >> b[i];
        b[i]+=1e4;
    }
    int cur = 0;
    for (int i = 1; i <= n ; i ++ ){
        for (int j = 1 ; j<= m ; j ++){
            c[a[i] + b[j]][i] = 1;
            c[a[i] + b[j]][j + n] = 1;
            val[++cur] = a[i] + b[j];
        }
    }
    sort(val + 1 , val + cur + 1);
    int ans = 0;
    for (int i = 1  ; i <= cur ; i ++){
        ans = max(ans , (int)c[val[i]].count());
        for (int j = i + 1 ; j <= cur ; j ++){
            ans = max(ans , (int)(c[val[i]]|c[val[j]]).count());
        }
    }
    cout << ans;

    return(0);
}

//When we hit our lowest point, we are open to the greatest change.
//If I try, I fail. If I don't try, I'm NEVER GOING TO GET IT.
//Sometimes, life is like this dark tunnel. You can't always see the light at the end of the tunnel. But if you just keep moving... you will come to a better place.
//It is important to draw wisdom from diffrent places. If you take it from only one place it becomes rigid and stale.


#pragma GCC optimize("O2")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx,avx2,sse,sse2,fma,tune=native")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int  ,int > pii;
typedef pair<ll  ,ll > pll;

const ll maxn =2e6;
const ll mod = 1e9+7;
const ld PI = 4 * atan((ld) 1);

#define pb(x) push_back(x);
#define endl '\n'
#define dokme(x) cout << x ;  return(0);
#define migmig ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define file_init freopen("input.txt", "r+", stdin); freopen("output.txt", "w+", stdout);
#define ms(x , y) memset(x , y , sizeof x);
ll pw(ll a, ll b) {
    return (!b ? 1 : (b & 1 ? a * pw(a * a % mod, b / 2) % mod : pw(a * a % mod, b / 2) % mod));
}

int n , m;
int a[maxn] , b[maxn] , val[maxn];
//bool c[1e5][500];
bitset < 500 > c[(int)1e5];
int main(){
    migmig
    cin >> n >> m;
    for (int i = 1 ; i <= n ; i ++){
        cin >> a[i];
        a[i]+=1e4;
    }
    for (int i = 1 ; i <= m ; i ++){
        cin >> b[i];
        b[i]+=1e4;
    }
    int cur = 0;
    for (int i = 1; i <= n ; i ++ ){
        for (int j = 1 ; j<= m ; j ++){
            c[a[i] + b[j]][i] = 1;
            c[a[i] + b[j]][j + n] = 1;
            val[++cur] = a[i] + b[j];
        }
    }
    sort(val + 1 , val + cur + 1);
    int ans = 0;
    for (int i = 1  ; i <= cur ; i ++){
        ans = max(ans , (int)c[val[i]].count());
        for (int j = i + 1 ; j <= cur ; j ++){
            ans = max(ans , (int)(c[val[i]]|c[val[j]]).count());
        }
    }
    cout << ans;

    return(0);
}

//When we hit our lowest point, we are open to the greatest change.
//If I try, I fail. If I don't try, I'm NEVER GOING TO GET IT.
//Sometimes, life is like this dark tunnel. You can't always see the light at the end of the tunnel. But if you just keep moving... you will come to a better place.
//It is important to draw wisdom from diffrent places. If you take it from only one place it becomes rigid and stale.


#include<bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef unsigned short int uns;
#define pii pair<int, int>
#define pll pair<ll, ll>
#define sync ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define FOR(i, a, b) for(int i = (a);i < (b);i++)
#define pb push_back
#define mp make_pair
#define pf push_front
#define fi first
#define se second
#define sqr(a) ((a) * (a))
#define pi 3.1415926535897932
#define eps 0.0000001
#define mod 1000000007
#define vii vector<int>
#define vll vector<ll>
#define mii map<int, int>
#define mll map<ll, ll>
#define vpp vector<pii>
//#define int ll

using namespace std;

int n, m, k;

const int mid = 20010;

vector <int> inf1, inf2;
int dat1[mid * 2 + 50];
int dat2[mid * 2 + 50];

int mx;

set <int> irr;
vector <int> ir;

bitset<60> dt1[3605];
///fdslfds;ldfs,;dfs
bitset<60> dt2[3605], tt, ttt;
//////sdfsdfdsdfsdfsdf
int dt11[3605], dt22[3605];

int main()
{
	int n, m, i, j, l, k, a, b, c, d, pos, tm;

	cin >> n >> m;
	for (i = 0; i < n; i++)
	{
		cin >> a;
		a *= 2;
		inf1.pb(a);
		dat1[a + mid] = 1;
	}
	for (i = 0; i < m; i++)
	{
		cin >> a;
		a *= 2;
		inf2.pb(a);
		dat2[a + mid] = 1;
	}

	for (i = 0; i < n; i++)
	{
		for (j = 0; j < m; j++)
		{
			irr.insert((inf1[i] + inf2[j]) / 2);
		}
	}

	for (auto it : irr)
	{
		ir.pb(it);
	}

	for (i = 0; i < ir.size(); i++)
	{
		for (j = 0; j < n; j++)
		{
			if (dat2[inf1[j] + (ir[i] - inf1[j]) * 2+mid] == 1)
			{
				dt1[i][j] = 1;
			}
		}
		for (j = 0; j < m; j++)
		{
			if (dat1[inf2[j] + (ir[i] - inf2[j]) * 2+mid] == 1)
			{
				dt2[i][j] = 1;
			}
		}
	}

	for (i = 0; i < ir.size(); i++)
	{
		dt11[i] = dt1[i].count();
		dt22[i] = dt2[i].count();
	}

	for (i = 0; i < ir.size(); i++)
	{

		for (j = 0; j < ir.size(); j++)
		{

			tt = dt1[i] | dt1[j];
			tm = tt.count();
			tt = dt2[i] | dt2[j];
			tm += tt.count();
			mx = max(tm, mx);
		}
	}

	cout << mx;

	return 0;
}


#include<bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef unsigned short int uns;
#define pii pair<int, int>
#define pll pair<ll, ll>
#define sync ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define FOR(i, a, b) for(int i = (a);i < (b);i++)
#define pb push_back
#define mp make_pair
#define pf push_front
#define fi first
#define se second
#define sqr(a) ((a) * (a))
#define pi 3.1415926535897932
#define eps 0.0000001
#define mod 1000000007
#define vii vector<int>
#define vll vector<ll>
#define mii map<int, int>
#define mll map<ll, ll>
#define vpp vector<pii>
//#define int ll

using namespace std;

int n, m, k;

const int mid = 20001;

vector <int> inf1, inf2;
int dat1[mid * 2 + 50];
int dat2[mid * 2 + 50];

int mx;

set <int> irr;
vector <int> ir;

bitset<60> dt1[3605];
///fdslfds;ldfs,;dfs
bitset<60> dt2[3605], tt, ttt;
//////sdfsdfdsdfsdfsdf
int dt11[3605], dt22[3605];

int main()
{
	int n, m, i, j, l, k, a, b, c, d, pos, tm;

	cin >> n >> m;
	for (i = 0; i < n; i++)
	{
		cin >> a;
		a *= 2;
		inf1.pb(a);
		dat1[a + mid] = 1;
	}
	for (i = 0; i < m; i++)
	{
		cin >> a;
		a *= 2;
		inf2.pb(a);
		dat2[a + mid] = 1;
	}

	for (i = 0; i < n; i++)
	{
		for (j = 0; j < m; j++)
		{
			irr.insert((inf1[i] + inf2[j]) / 2);
		}
	}

	for (auto it : irr)
	{
		ir.pb(it);
	}

	for (i = 0; i < ir.size(); i++)
	{
		for (j = 0; j < n; j++)
		{
			if (dat2[inf1[j] + (ir[i] - inf1[j]) * 2+mid] == 1)
			{
				dt1[i][j] = 1;
			}
		}
		for (j = 0; j < m; j++)
		{
			if (dat1[inf2[j] + (ir[i] - inf2[j]) * 2+mid] == 1)
			{
				dt2[i][j] = 1;
			}
		}
	}

	for (i = 0; i < ir.size(); i++)
	{
		dt11[i] = dt1[i].count();
		dt22[i] = dt2[i].count();
	}

	for (i = 0; i < ir.size(); i++)
	{

		for (j = 0; j < ir.size(); j++)
		{

			tt = dt1[i] | dt1[j];
			tm = tt.count();
			tt = dt2[i] | dt2[j];
			tm += tt.count();
			mx = max(tm, mx);
		}
	}

	cout << mx;

	return 0;
}


#include<bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef unsigned short int uns;
#define pii pair<int, int>
#define pll pair<ll, ll>
#define sync ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define FOR(i, a, b) for(int i = (a);i < (b);i++)
#define pb push_back
#define mp make_pair
#define pf push_front
#define fi first
#define se second
#define sqr(a) ((a) * (a))
#define pi 3.1415926535897932
#define eps 0.0000001
#define mod 1000000007
#define vii vector<int>
#define vll vector<ll>
#define mii map<int, int>
#define mll map<ll, ll>
#define vpp vector<pii>
//#define int ll

using namespace std;

int n, m, k;

const int mid = 220001;

vector <int> inf1, inf2;
int dat1[mid * 2 + 50];
int dat2[mid * 2 + 50];

int mx;

set <int> irr;
vector <int> ir;

bitset<60> dt1[3605];
///fdslfds;ldfs,;dfs
bitset<60> dt2[3605], tt, ttt;
//////sdfsdfdsdfsdfsdf
int dt11[3605], dt22[3605];

int main()
{
	int n, m, i, j, l, k, a, b, c, d, pos, tm;

	cin >> n >> m;
	for (i = 0; i < n; i++)
	{
		cin >> a;
		a *= 2;
		inf1.pb(a);
		dat1[a + mid] = 1;
	}
	for (i = 0; i < m; i++)
	{
		cin >> a;
		a *= 2;
		inf2.pb(a);
		dat2[a + mid] = 1;
	}

	for (i = 0; i < n; i++)
	{
		for (j = 0; j < m; j++)
		{
			irr.insert((inf1[i] + inf2[j]) / 2);
		}
	}

	for (auto it : irr)
	{
		ir.pb(it);
	}

	for (i = 0; i < ir.size(); i++)
	{
		for (j = 0; j < n; j++)
		{
			if (dat2[inf1[j] + (ir[i] - inf1[j]) * 2+mid] == 1)
			{
				dt1[i][j] = 1;
			}
		}
		for (j = 0; j < m; j++)
		{
			if (dat1[inf2[j] + (ir[i] - inf2[j]) * 2+mid] == 1)
			{
				dt2[i][j] = 1;
			}
		}
	}

	for (i = 0; i < ir.size(); i++)
	{
		dt11[i] = dt1[i].count();
		dt22[i] = dt2[i].count();
	}

	for (i = 0; i < ir.size(); i++)
	{

		for (j = 0; j < ir.size(); j++)
		{

			tt = dt1[i] | dt1[j];
			tm = tt.count();
			tt = dt2[i] | dt2[j];
			tm += tt.count();
			mx = max(tm, mx);
		}
	}

	cout << mx;

	return 0;
}


#include<bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef unsigned short int uns;
#define pii pair<int, int>
#define pll pair<ll, ll>
#define sync ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define FOR(i, a, b) for(int i = (a);i < (b);i++)
#define pb push_back
#define mp make_pair
#define pf push_front
#define fi first
#define se second
#define sqr(a) ((a) * (a))
#define pi 3.1415926535897932
#define eps 0.0000001
#define mod 1000000007
#define vii vector<int>
#define vll vector<ll>
#define mii map<int, int>
#define mll map<ll, ll>
#define vpp vector<pii>
//#define int ll

using namespace std;

int n, m, k;

const int mid = 20000;

vector <int> inf1, inf2;
int dat1[mid * 2 + 50];
int dat2[mid * 2 + 50];

int mx;

set <int> irr;
vector <int> ir;

bitset<60> dt1[3605];
///fdslfds;ldfs,;dfs
bitset<60> dt2[3605], tt, ttt;
//////sdfsdfdsdfsdfsdf
int dt11[3605], dt22[3605];

int main()
{
	int n, m, i, j, l, k, a, b, c, d, pos, tm;

	cin >> n >> m;
	for (i = 0; i < n; i++)
	{
		cin >> a;
		a *= 2;
		inf1.pb(a);
		dat1[a + mid] = 1;
	}
	for (i = 0; i < m; i++)
	{
		cin >> a;
		a *= 2;
		inf2.pb(a);
		dat2[a + mid] = 1;
	}

	for (i = 0; i < n; i++)
	{
		for (j = 0; j < m; j++)
		{
			irr.insert((inf1[i] + inf2[j]) / 2);
		}
	}

	for (auto it : irr)
	{
		ir.pb(it);
	}

	for (i = 0; i < ir.size(); i++)
	{
		for (j = 0; j < n; j++)
		{
			if (dat2[inf1[j] + (ir[i] - inf1[j]) * 2+mid] == 1)
			{
				dt1[i][j] = 1;
			}
		}
		for (j = 0; j < m; j++)
		{
			if (dat1[inf2[j] + (ir[i] - inf2[j]) * 2+mid] == 1)
			{
				dt2[i][j] = 1;
			}
		}
	}

	for (i = 0; i < ir.size(); i++)
	{
		dt11[i] = dt1[i].count();
		dt22[i] = dt2[i].count();
	}

	for (i = 0; i < ir.size(); i++)
	{

		for (j = 0; j < ir.size(); j++)
		{

			tt = dt1[i] | dt1[j];
			tm = tt.count();
			tt = dt2[i] | dt2[j];
			tm += tt.count();
			mx = max(tm, mx);
		}
	}

	cout << mx;

	return 0;
}


#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <functional>
#include <vector>
#include <list>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <unordered_map>
#include <sstream>
#include <tuple>
#include <cassert>
#include <set>
#include <unordered_set>

#ifdef NON_SUBMIT
#ifndef COMPARE
#define TEST(n) (n)
#else
#define TEST(n) ((void)0)
#endif
#else
#define TEST(n) ((void)0)
#endif

using namespace std;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
#ifdef NON_SUBMIT
#ifdef COMPARE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
#endif
	int N, M, result = 0;
	map<int, set<int>> cnt;
	bool chk[120];
	vector<int> Ym, YM;
	cin >> N >> M;
	Ym.resize(N);
	YM.resize(M);
	for (auto &y : Ym) {
		cin >> y;
		y *= 2;
	}
	for (auto &y : YM) {
		cin >> y;
		y *= 2;
	}
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < M; j++) {
			cnt[(Ym[i] + YM[j]) / 2].insert(i);
			cnt[(Ym[i] + YM[j]) / 2].insert(N + j);
		}
	}
	for (auto &[t1, a1] : cnt) {
		for (auto &[t2, a2] : cnt) {
			int temp = 0;
			memset(chk, 0, sizeof(chk));
			for (auto x : a1) {
				if (!chk[x]) {
					chk[x] = true;
					temp++;
				}
			}
			for (auto x : a2) {
				if (!chk[x]) {
					chk[x] = true;
					temp++;
				}
			}
			result = max(result, temp);
		}
	}
	cout << result << '\n';
#ifdef NON_SUBMIT
#ifndef COMPARE
	system("PAUSE");
#endif
#endif
	return 0;
}


#include <iostream>
#include <vector>
#include <set>
#include <string>
#include <algorithm>

using namespace std;

int main() {
	int n, m, ans = 0, s, k;
	cin >> n >> m;
	vector <int> pos(100000, -1);
	vector <int> a(n), b(m), t;
	for (int i = 0; i < n; i++)
		cin >> a[i];
	for (int i = 0; i < m; i++)
		cin >> b[i];
	vector <vector <int> > now;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			if (pos[a[i] + b[j] + 20000] == -1) {
				pos[a[i] + b[j] + 20000] = now.size();
				t.clear();
				t.push_back(i);
				t.push_back(j + n);
				now.push_back(t);
			}
			else {
				now[pos[a[i] + b[j] + 20000]].push_back(i);
				now[pos[a[i] + b[j] + 20000]].push_back(j + n);
			}
		}
	}
	vector <bool> can;
	k = now.size();
	for (int i = 0; i < k; i++) {
		for (int j = 0; j < k; j++) {
			can.assign(n + m, false);
			s = 0;
			for (int o = 0; o < now[i].size(); o++) {
				if (!can[now[i][o]]) {
					can[now[i][o]] = true;
					s++;
				}
			}
			for (int o = 0; o < now[j].size(); o++)
				if (!can[now[j][o]]) {
					can[now[j][o]] = true;
					s++;
				}
			ans = max(ans, s);
		}
	}
	cout << ans;
	//system("pause");
}


#include <iostream>
#include <vector>
#include <set>
#include <string>
#include <algorithm>

using namespace std;

int main() {
	int n, m, ans = 0, s, k;
	cin >> n >> m;
	vector <int> pos(100000, -1);
	vector <int> a(n), b(m), t;
	for (int i = 0; i < n; i++)
		cin >> a[i];
	for (int i = 0; i < m; i++)
		cin >> b[i];
	vector <vector <int> > now;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			if (pos[a[i] + b[j] + 20000] == -1) {
				pos[a[i] + b[j] + 20000] = now.size();
				t.clear();
				t.push_back(i);
				t.push_back(j + n);
				now.push_back(t);
			}
			else {
				now[pos[a[i] + b[j] + 20000]].push_back(i);
				now[pos[a[i] + b[j] + 20000]].push_back(j + n);
			}
		}
	}
	vector <bool> can;
	k = now.size();
	for (int i = 0; i < k; i++) {
		for (int j = 0; j < k; j++) {
			can.assign(n + m, false);
			s = now[i].size() + now[j].size();
			for (int o = 0; o < now[i].size(); o++)
				can[now[i][o]] = true;
			for (int o = 0; o < now[j].size(); o++)
				if (can[now[j][o]])
					s--;
			ans = max(ans, s);
		}
	}
	cout << ans;
	//system("pause");
}


//
//  main.cpp
//  Careful Maneuvering
//
//  Created by Augustinas Jucas on 07/07/2019.
//  Copyright © 2019 Augustinas Jucas. All rights reserved.
//

#include <iostream>
#include <set>
#include <vector>

using namespace std;

const int dydis = 30004;

int Kmasyvas[2*dydis+2] = {0};
int Dmasyvas[2*dydis+2] = {0};

bool usedL[2*dydis+2] = {false};
bool usedR[2*dydis+2] = {false};

int main(int argc, const char * argv[]) {

    int ats = 0;
    int n, m;
    cin >> n >> m;

    vector<int> kaire;
    vector<int> desine;

    for(int i = 0; i < n; i++){
        int a;
        cin >> a;
        if(!usedL[a+dydis]) kaire.push_back(a);
        usedL[a+dydis] = true;
        Kmasyvas[dydis+a]++;
    }
    for(int i = 0; i < m; i++){
        int a;
        cin >> a;
        if(!usedR[a+dydis]) desine.push_back(a);
        usedR[a+dydis] = true;

        Dmasyvas[dydis+a]++;
    }

    set<double> taskas;
    for(int i = 0; i < kaire.size(); i++){
        for(int j = 0; j < desine.size(); j++){
            taskas.insert(((double)((double)(kaire[i]+desine[j])/(double)2)));
            //cout << (kaire[i]+desine[j])/2 << endl;
        }
    }
    for(auto pirmas = taskas.begin(); pirmas != taskas.end(); pirmas++){

        bool killKmasyvas[2*dydis+2] = {false};
        bool killDmasyvas[2*dydis+2] = {false};
        int suma = 0;

        for(int i = 0; i < kaire.size(); i++){ // einam per kairius taskus ir ieskom kur susidaus
            int desKord = *pirmas + (*pirmas - kaire[i]);
            if(Dmasyvas[dydis+desKord] > 0){
                if(!killKmasyvas[dydis+kaire[i]]) suma += Kmasyvas[dydis+kaire[i]];
                if(!killDmasyvas[dydis+desKord]) suma += Dmasyvas[dydis+desKord];
                killKmasyvas[dydis+kaire[i]] = true;
                killDmasyvas[dydis+desKord] = true;
            }
        }
        //cout << "Kai pirmas taskas yra " << *pirmas << ", tai nuzudomi " << suma << " laivai. " << endl;

        for(auto antras = taskas.begin(); antras != taskas.end(); antras++){
            if(*pirmas == *antras) continue;
            int sitoSuma = 0;
            for(int i = 0; i < kaire.size(); i++){ // einam per kairius taskus ir ieskom kur susidaus
                int desKord = *antras + (*antras - kaire[i]);
                if(Dmasyvas[dydis+desKord] > 0){
                    if(!killKmasyvas[dydis+kaire[i]]) sitoSuma += Kmasyvas[dydis+kaire[i]];
                    if(!killDmasyvas[dydis+desKord]) sitoSuma += Dmasyvas[dydis+desKord];
                }
            }

            //cout << "Kai prie " << *pirmas << " prisiededa " << *antras << ", tai nuzudomi " << sitoSuma+suma << " laivai." << endl;
            ats = max(ats, sitoSuma+suma);

        }
    }
    cout << ats;

    return 0;
}


//
//  main.cpp
//  Careful Maneuvering
//
//  Created by Augustinas Jucas on 07/07/2019.
//  Copyright © 2019 Augustinas Jucas. All rights reserved.
//

#include <iostream>
#include <set>
#include <vector>

using namespace std;

const int dydis = 30004;

int Kmasyvas[2*dydis+2] = {0};
int Dmasyvas[2*dydis+2] = {0};

bool usedL[2*dydis+2] = {false};
bool usedR[2*dydis+2] = {false};

int main(int argc, const char * argv[]) {

    int ats = 0;
    int n, m;
    cin >> n >> m;

    vector<int> kaire;
    vector<int> desine;

    for(int i = 0; i < n; i++){
        int a;
        cin >> a;
        if(!usedL[a+dydis]) kaire.push_back(a);
        usedL[a+dydis] = true;
        Kmasyvas[dydis+a]++;
    }
    for(int i = 0; i < m; i++){
        int a;
        cin >> a;
        if(!usedR[a+dydis]) desine.push_back(a);
        usedR[a+dydis] = true;

        Dmasyvas[dydis+a]++;
    }

    set<double> taskas;
    for(int i = 0; i < kaire.size(); i++){
        for(int j = 0; j < desine.size(); j++){
            taskas.insert(((double)((double)(kaire[i]+desine[j])/(double)2)));
            //cout << (kaire[i]+desine[j])/2 << endl;
        }
    }
    for(auto pirmas = taskas.begin(); pirmas != taskas.end(); pirmas++){

        bool killKmasyvas[2*dydis+2] = {false};
        bool killDmasyvas[2*dydis+2] = {false};
        int suma = 0;

        for(int i = 0; i < kaire.size(); i++){ // einam per kairius taskus ir ieskom kur susidaus
            int desKord = *pirmas + (*pirmas - kaire[i]);
            if(Dmasyvas[dydis+desKord] > 0){
                if(!killKmasyvas[dydis+kaire[i]]) suma += Kmasyvas[dydis+kaire[i]];
                if(!killDmasyvas[dydis+desKord]) suma += Dmasyvas[dydis+desKord];
                killKmasyvas[dydis+kaire[i]] = true;
                killDmasyvas[dydis+desKord] = true;
            }
        }
        //cout << "Kai pirmas taskas yra " << *pirmas << ", tai nuzudomi " << suma << " laivai. " << endl;
        ats = max(ats, suma);
        for(auto antras = pirmas; antras != taskas.end(); antras++){
            if(*pirmas == *antras) continue;
            int sitoSuma = 0;
            for(int i = 0; i < kaire.size(); i++){ // einam per kairius taskus ir ieskom kur susidaus
                int desKord = *antras + (*antras - kaire[i]);
                if(Dmasyvas[dydis+desKord] > 0){
                    if(!killKmasyvas[dydis+kaire[i]]) sitoSuma += Kmasyvas[dydis+kaire[i]];
                    if(!killDmasyvas[dydis+desKord]) sitoSuma += Dmasyvas[dydis+desKord];
                }
            }

            //cout << "Kai prie " << *pirmas << " prisiededa " << *antras << ", tai nuzudomi " << sitoSuma+suma << " laivai." << endl;
            ats = max(ats, sitoSuma+suma);

        }
    }
    cout << ats;

    return 0;
}


//
//  main.cpp
//  Careful Maneuvering
//
//  Created by Augustinas Jucas on 07/07/2019.
//  Copyright © 2019 Augustinas Jucas. All rights reserved.
//

#include <iostream>
#include <set>
#include <vector>

using namespace std;

const int dydis = 30004;

int Kmasyvas[2*dydis+2] = {0};
int Dmasyvas[2*dydis+2] = {0};

bool usedL[2*dydis+2] = {false};
bool usedR[2*dydis+2] = {false};

int main(int argc, const char * argv[]) {

    int ats = 0;
    int n, m;
    cin >> n >> m;

    vector<int> kaire;
    vector<int> desine;

    for(int i = 0; i < n; i++){
        int a;
        cin >> a;
        if(!usedL[a+dydis]) kaire.push_back(a);
        usedL[a+dydis] = true;
        Kmasyvas[dydis+a]++;
    }
    for(int i = 0; i < m; i++){
        int a;
        cin >> a;
        if(!usedR[a+dydis]) desine.push_back(a);
        usedR[a+dydis] = true;

        Dmasyvas[dydis+a]++;
    }

    set<double> taskas;
    for(int i = 0; i < kaire.size(); i++){
        for(int j = 0; j < desine.size(); j++){
         //   //cout << kaire[i] << " su " << desine[j] << " susiduria ";
            double x1 = -100;
            double y1 = kaire[i];
            double x2 = 100;
            double y2 = desine[j];
            taskas.insert((kaire[i]+desine[j])/2);
            //cout << (kaire[i]+desine[j])/2 << endl;

        }
    }
    for(auto pirmas = taskas.begin(); pirmas != taskas.end(); pirmas++){

        bool killKmasyvas[2*dydis+2] = {false};
        bool killDmasyvas[2*dydis+2] = {false};
        int suma = 0;

        for(int i = 0; i < kaire.size(); i++){ // einam per kairius taskus ir ieskom kur susidaus
            int desKord = *pirmas + (*pirmas - kaire[i]);
            if(Dmasyvas[dydis+desKord] > 0){
                if(!killKmasyvas[dydis+kaire[i]]) suma += Kmasyvas[dydis+kaire[i]];
                if(!killDmasyvas[dydis+desKord]) suma += Dmasyvas[dydis+desKord];
                killKmasyvas[dydis+kaire[i]] = true;
                killDmasyvas[dydis+desKord] = true;
            }
        }
        //cout << "Kai pirmas taskas yra " << *pirmas << ", tai nuzudomi " << suma << " laivai. " << endl;

        for(auto antras = taskas.begin(); antras != taskas.end(); antras++){
            int sitoSuma = 0;
            for(int i = 0; i < kaire.size(); i++){ // einam per kairius taskus ir ieskom kur susidaus
                int desKord = *antras + (*antras - kaire[i]);
                if(Dmasyvas[dydis+desKord] > 0){
                    if(!killKmasyvas[dydis+kaire[i]]) sitoSuma += Kmasyvas[dydis+kaire[i]];
                    if(!killDmasyvas[dydis+desKord]) sitoSuma += Dmasyvas[dydis+desKord];
                }
            }

            //cout << "Kai prie " << *pirmas << " prisiededa " << *antras << ", tai nuzudomi " << sitoSuma+suma << " laivai." << endl;
            ats = max(ats, sitoSuma+suma);

        }
    }
    cout << ats;

    return 0;
}


//
//  main.cpp
//  Careful Maneuvering
//
//  Created by Augustinas Jucas on 07/07/2019.
//  Copyright © 2019 Augustinas Jucas. All rights reserved.
//

#include <iostream>
#include <set>
#include <vector>

using namespace std;

const int dydis = 10000;

int Kmasyvas[2*dydis+2] = {0};
int Dmasyvas[2*dydis+2] = {0};

int main(int argc, const char * argv[]) {

    int ats = 0;
    int n, m;
    cin >> n >> m;

    vector<int> kaire;
    vector<int> desine;

    for(int i = 0; i < n; i++){
        int a;
        cin >> a;
        kaire.push_back(a);
        Kmasyvas[dydis+a]++;
    }
    for(int i = 0; i < m; i++){
        int a;
        cin >> a;
        desine.push_back(a);
        Dmasyvas[dydis+a]++;
    }

    set<double> taskas;
    for(int i = 0; i < n; i++){
        for(int j = 0; j < m; j++){
         //   //cout << kaire[i] << " su " << desine[j] << " susiduria ";
            double x1 = -100;
            double y1 = kaire[i];
            double x2 = 100;
            double y2 = desine[j];
            taskas.insert(y1 - (((y1-y2)/(x1-x2))*x1));
            //cout << y1 - (((y1-y2)/(x1-x2))*x1) << endl;

        }
    }
    for(auto pirmas = taskas.begin(); pirmas != taskas.end(); pirmas++){

        bool killKmasyvas[2*dydis+2] = {false};
        bool killDmasyvas[2*dydis+2] = {false};
        int suma = 0;

        for(int i = 0; i < n; i++){ // einam per kairius taskus ir ieskom kur susidaus
            int desKord = *pirmas + (*pirmas - kaire[i]);
            if(Dmasyvas[dydis+desKord] > 0){
                if(!killKmasyvas[dydis+kaire[i]]) suma += Kmasyvas[dydis+kaire[i]];
                if(!killDmasyvas[dydis+desKord]) suma += Dmasyvas[dydis+desKord];
                killKmasyvas[dydis+kaire[i]] = true;
                killDmasyvas[dydis+desKord] = true;
            }
        }
        //cout << "Kai pirmas taskas yra " << *pirmas << ", tai nuzudomi " << suma << " laivai. " << endl;

        for(auto antras = taskas.begin(); antras != taskas.end(); antras++){
            int sitoSuma = 0;
            for(int i = 0; i < n; i++){ // einam per kairius taskus ir ieskom kur susidaus
                int desKord = *antras + (*antras - kaire[i]);
                if(Dmasyvas[dydis+desKord] > 0){
                    if(!killKmasyvas[dydis+kaire[i]]) sitoSuma += Kmasyvas[dydis+kaire[i]];
                    if(!killDmasyvas[dydis+desKord]) sitoSuma += Dmasyvas[dydis+desKord];
                }
            }

            //cout << "Kai prie " << *pirmas << " prisiededa " << *antras << ", tai nuzudomi " << sitoSuma+suma << " laivai." << endl;
            ats = max(ats, sitoSuma+suma);

        }
    }
    cout << ats;

    return 0;
}


#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
using namespace std;
using ll=long long;
int main() {
    ios::sync_with_stdio(0), cin.tie(0);

    bitset<100000> bs;
    int curr=0, m=0;
    int n;
    cin>>n;
    while(--n>=0) {
        int a;
        cin>>a;
        if(!bs[a-1])
            ++curr;
        else
            curr=0;
        m=max(m, curr);
        bs.flip(a-1);
    }
    cout<<m;

    return 0;
}


#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
using namespace std;
using ll=long long;
bool arr[100000] {};
int main() {
    ios::sync_with_stdio(0), cin.tie(0);

    int curr=0, m=0;
    int n;
    cin>>n;
    while(--n>=0) {
        int a;
        cin>>a;
        if(!arr[a-1])
            ++curr;
        else
            --curr;
        m=max(m, curr);
        arr[a-1]=true;
    }
    cout<<m;

    return 0;
}


#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
using namespace std;
using ll=long long;
int main() {
    ios::sync_with_stdio(0), cin.tie(0);

    bitset<100000> bs;
    int curr=0, m=0;
    int n;
    cin>>n;
    while(--n>=0) {
        int a;
        cin>>a;
        if(!bs[a-1])
            ++curr;
        else
            --curr;
        m=max(m, curr);
        bs.flip(a-1);
    }
    cout<<m;

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

const int M = 1e5 + 5;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int n;
  cin >> n;
  bitset<M> bs;
  int mx = 0;
  for (int i = 0, a; i < n * 2; i++) {
    cin >> a;
    bs ^= (1 << (a - 1));
    mx = max(mx, (int) bs.count());
  }
  cout << mx;
  return 0;
}


#include <bits/stdc++.h>

using namespace std;

const int M = 1e5 + 5;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int n;
  cin >> n;
  bitset<M> bs;
  int mx = 0;
  for (int i = 0, a; i < n * 2; i++) {
    cin >> a;
    bs ^= (1 << a);
    mx = max(mx, (int) bs.count());
  }
  cout << mx;
  return 0;
}


#include <bits/stdc++.h>

using namespace std;

const int M = 2e5 + 100;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int n;
  cin >> n;
  bitset<M> bs;
  int mx = 0;
  for (int i = 0, a; i < n * 2; i++) {
    cin >> a;
    bs[a] = bs[a] ? false : true;
    mx = max(mx, (int) bs.count());
  }
  cout << mx;
  return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int n;
  cin >> n;
  int mx = 0;
  unordered_set<int> se;
  for (int i = 0, a; i < n * 2; i++) {
    cin >> a;
    if (se.count(a))
      se.erase(a);
    else se.insert(a);
    mx = max(mx, (int) se.size());
  }
  cout << mx;
  return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int n;
  cin >> n;
  int mx = 0;
  set<int> se;
  for (int i = 0, a; i < n * 2; i++) {
    cin >> a;
    if (se.count(a))
      se.erase(a);
    else se.insert(a);
    mx = max(mx, (int) se.size());
  }
  cout << mx;
  return 0;
}


#include <bits/stdc++.h>
#define ll long long
using namespace std;
const ll N = 1e5 + 7;
ll n , a[N] , mx , sz , ans , to ;
bool used[N];
int main ()
{
 cin >> n;

    for ( ll i = 1; i <= n * 2; i ++ )
    {
        cin >> a[i];
    }
    for ( ll i = 1 ; i <= n * 2; i ++ )
    {
        to = a[i];
        if ( !used[to] )
        {
            ans ++ ;
        }
        if ( used[to])
        {
            ans --;
        }
        mx = max ( ans , mx );
        used[to] = true ;
    }
    cout << mx ;
}


#include <bits/stdc++.h>
#define ll long long
using namespace std;
const ll N = 2 * 1e5 + 7;
ll n , a[N] , mx , sz ;
set < ll > s;
int main ()
{
 cin >> n;

    for ( ll i = 1; i <= n * 2; i ++ )
    {
        cin >> a[i];
    }
    for ( ll i = 1 ; i <= n * 2; i ++ )
    {
        for ( auto c : s)
        {
            if ( c == a[i] )
            {
                s.erase(a[i]);
                i ++;
                break;
            }
        }
     s.insert(a[i]);
     sz = s.size();
     mx = max ( mx , sz );

    }
    cout << mx;
}


#include <bits/stdc++.h>
#define ll long long
using namespace std;
const ll N = (2*1e5) + 7;
ll n , a[N] , mx , sz , ans , to ;
bool used[N];
int main ()
{
 cin >> n;

    for ( ll i = 1; i <= n * 2; i ++ )
    {
        cin >> a[i];
    }
    for ( ll i = 1 ; i <= n * 2; i ++ )
    {
        to = a[i];
        if ( !used[to] )
        {
            ans ++ ;
        }
        if ( used[to])
        {
            ans --;
        }
        mx = max ( ans , mx );
        used[to] = true ;
    }
    cout << mx ;
}


#include <bits/stdc++.h>
#define ll long long
using namespace std;
const ll N = 2 * 1e5 + 7;
ll n , a[N] , mx , sz , ans , to ;
bool used[N];
int main ()
{
 cin >> n;

    for ( ll i = 1; i <= n * 2; i ++ )
    {
        cin >> a[i];

        to = a[i];
        if ( !used[to] )
        {
            ans ++ ;
        }
        if ( used[to])
        {
            ans --;
        }
        mx = max ( ans , mx );
        used[to] = true ;
    }
    cout << mx ;
}


#include <bits/stdc++.h>
#define ll long long
using namespace std;
const ll N = 1e5 + 7;
ll n , a[N] , mx , sz , ans , to ;
bool used[N];
int main ()
{
 cin >> n;

    for ( ll i = 1; i <= n * 2; i ++ )
    {
        cin >> a[i];
    }
    for ( ll i = 1 ; i <= n * 2; i ++ )
    {
        to = a[i];
        if ( !used[to] )
        {
            ans ++ ;
        }
        else
        {
            ans --;
        }
        mx = max ( ans , mx );
        used[to] = true ;
    }
    cout << mx ;
}


#include <bits/stdc++.h>
#define ll long long
using namespace std;
const ll N = 1e5 + 7;
ll n , a[N] , mx , sz ;
set < ll > s;
int main ()
{
 cin >> n;

    for ( ll i = 1; i <= n * 2; i ++ )
    {
        cin >> a[i];
    }
    for ( ll i = 1 ; i <= n * 2; i ++ )
    {
        for ( auto c : s)
        {
            if ( c == a[i] )
            {
                s.erase(a[i]);
                i ++;
                break;
            }
        }
     s.insert(a[i]);
     sz = s.size();
     mx = max ( mx , sz );

    }
    cout << mx;
}


#include<bits/stdc++.h>
#define I_AM_SPEED ios_base::sync_with_stdio(false); cin.tie(NULL)
#define ll long long
#define arr(A,N) sort(A,A+N)
#define rev(A,N) sort(A,A+N,greater<int>())
using namespace std;
int main()
{
    ll N,i,A[100500]={},maz=0,x,cur=0,N1,N2;
    cin>>N;
    N1=N;
    N2=2*N-N1;
    while(N1--)
    {
        cin>>x;
        A[x]++;
        if(A[x]==1) cur++;
        if(A[x]==2) cur=cur-2;
        if(cur>=maz) maz=cur;
    }
    while(N2--)
    {
        cin>>x;
        A[x]++;
        if(A[x]==1) cur++;
        if(A[x]==2) cur=cur-2;
        if(cur>=maz) maz=cur;
    }
    cout<<maz;
    return 0;
}


#include<bits/stdc++.h>
#define I_AM_SPEED ios_base::sync_with_stdio(false); cin.tie(NULL)
#define ll long long
#define arr(A,N) sort(A,A+N)
#define rev(A,N) sort(A,A+N,greater<int>())
using namespace std;
int main()
{
    ll N,i,A[100500]={},maz=0,x,cur=0;
    cin>>N;
    N=2*N;
    while(N--)
    {
        cin>>x;
        A[x]++;
        if(A[x]==1) cur++;
        if(A[x]==2) cur=cur-2;
        if(cur>=maz) maz=cur;
    }
    cout<<maz;
    return 0;
}


#include<bits/stdc++.h>
#define I_AM_SPEED ios_base::sync_with_stdio(false); cin.tie(NULL)
#define ll long long
#define arr(A,N) sort(A,A+N)
#define rev(A,N) sort(A,A+N,greater<int>())
using namespace std;
int A[10000500]={};
int main()
{
    ll N,i,maz=0,x,cur=0,N1,N2;
    cin>>N;
    N=2*N;
    while(N--)
    {
        cin>>x;
        A[x]++;
        if(A[x]==1) cur++;
        if(A[x]==2) cur--;
        if(cur>=maz) maz=cur;
    }
    cout<<maz;
    return 0;
}


#include<bits/stdc++.h>
#define I_AM_SPEED ios_base::sync_with_stdio(false); cin.tie(NULL)
#define ll long long
#define arr(A,N) sort(A,A+N)
#define rev(A,N) sort(A,A+N,greater<int>())
using namespace std;
int A[10000500]={};
int main()
{
    ll N,i,maz=0,x,cur=0,N1,N2;
    cin>>N;
    N1=N;
    N2=2*N-N1;
    while(N1--)
    {
        cin>>x;
        A[x]++;
        if(A[x]==1) cur++;
        if(A[x]==2) cur=cur-2;
        if(cur>=maz) maz=cur;
    }
    while(N2--)
    {
        cin>>x;
        A[x]++;
        if(A[x]==1) cur++;
        if(A[x]==2) cur=cur-2;
        if(cur>=maz) maz=cur;
    }
    cout<<maz;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main()
{
    int n;
    cin>>n;
    int m=n*2;
    int a[m];
    int b=0;
    bool w=0;
    for(int i=0;i<m;i++){
        cin>>a[i];
    }
    for(int j=m-1;j>=(m/2);j--){
       for(int k=j+1;k<=m-1;k++){
                if(a[j]==a[k]){
                    w=1;
                    break;

            }
        }
        if(w){
            break;
        }
        else{
           b++;
        }

    }
    cout<<b;

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main()
{
    int n;
    cin>>n;
    int m=n*2;
    int a[m];
    int b=1;
    for(int i=0;i<m;i++){
        cin>>a[i];
    }
    for(int j=m-1;j>0;j--){
        if((a[j])!=(a[j-1])){
            b++;
            a[j-1]=a[j];
        }
        else{
            break;
        }
    }
    cout<<b;

    return 0;
}


#include <bits/stdc++.h>

using namespace std;
map<long long ,int>mp;
int main()
{
   long long n;
   cin>>n;
   long long m=2*n;
   long long a[m];
   long long t=0,ans=0;
   for(int i=0;i<m;i++){
    cin>>a[i];
    mp[a[i]]++;
    if(mp[a[i]]==1){
        t++;
    }
    else {t--;

    }
    ans=max(t,ans);
   }
   cout<<ans;

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main()
{
    long long n;
    cin>>n;
    long long m=n*2;
    long long a[m];
    long long b=0;
    bool w=0;
    for(int i=0;i<m;i++){
        cin>>a[i];
    }
    for(int j=m-1;j>=(m/2);j--){
       for(int k=j+1;k<=m-1;k++){
                if(a[j]==a[k]){
                    w=1;
                    break;

            }
        }
        if(w){
            break;
        }
        else{
           b++;
        }

    }
    cout<<b;

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n, max = 0, p = 0, c = 0;
    cin >> n;
    vector<int> aa(n*2);
    vector<int> table;
    for (int i = 0; i < n*2; i++) {
        cin >> aa[i];
    }

    for (int i = 0; i < n*2; i++) {
        if(table.end() != find(table.begin(), table.end(), aa[i])){
            if(max < table.size()){
                max = table.size();
            }
            table.clear();
            table.push_back(aa[i]);
        }else{
            table.push_back(aa[i]);
            if(max < table.size()){
                max = table.size();
            }
        }
    }
    cout <<max<< endl;

}


#include <bits/stdc++.h>

using namespace std;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n, max = 0, p = 0, c = 0;
    cin >> n;
    vector<int> aa(n*2);
    vector<int> table;
    for (int i = 0; i < n*2; i++) {
        cin >> aa[i];
    }

    for (int i = 0; i < n*2; i++) {
        std::vector<int>::iterator it;
        it = find(table.begin(), table.end(), aa[i]);
        if(table.end() != it){
            if(max < table.size()){
                max = table.size();
            }
            table.erase(table.begin()+distance(table.begin(), it));
        }else{
            table.push_back(aa[i]);
            if(max < table.size()){
                max = table.size();
            }
        }
    }
    cout <<max<< endl;

}


#include <bits/stdc++.h>

using namespace std;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n, max = 0, p = 0, c = 0;
    cin >> n;
    vector<int> aa(n*2);
    vector<int> table;
    for (int i = 0; i < n*2; i++) {
        cin >> aa[i];
    }

    for (int i = 0; i < n*2; i++) {
        if(table.end() != find(table.begin(), table.end(), aa[i])){
            if(max < table.size()){
                max = table.size();
            }
            table.clear();
        }else{
            table.push_back(aa[i]);
            if(max < table.size()){
                max = table.size();
            }
        }
    }
    cout <<max<< endl;

}


#include <bits/stdc++.h>

using namespace std;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n, max = 0, p = 0, c = 0;
    cin >> n;
    vector<int> aa(n*2);
    vector<int> table;
    for (int i = 0; i < n*2; i++) {
        cin >> aa[i];
    }

    for (int i = 0; i < n*2; i++) {
        if(table.end() != find(table.begin(), table.end(), aa[i])){
            if(max < table.size()){
                max = table.size();
            }
            table.clear();
        }else{
            table.push_back(aa[i]);
        }
    }
    cout <<max<< endl;

}


#include <bits/stdc++.h>

using namespace std;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n, max = 0, p = 0, c = 0;
    cin >> n;
    vector<int> aa(n*2);
    vector<int> table;
    map<int, int> mymap;
    for (int i = 0; i < n*2; i++) {
        cin >> aa[i];
    }
    for (int i = 0; i < n*2; i++) {

        if(mymap[aa[i]] == aa[i]){
            if(max < mymap.size()){
                max = mymap.size();
            }
            mymap.erase(aa[i]);
        }else{
            mymap[aa[i]] = aa[i];
            if(max < mymap.size()){
                max = mymap.size();
            }
        }
    }
    cout <<max<< endl;

}


#include <bits/stdc++.h>

using namespace std;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n, max = 0, p = 0, c = 0;
    cin >> n;
    vector<int> aa(n*2);
    for (int i = 0; i < n*2; i++) {
        cin >> aa[i];
    }
    for (int i = 0; i < n*2; i++) {
        if(aa[i] != p){
            c++;
            if(c > max){
                max = c;
                c = 0;
            }
            p = aa[i];
        }
    }
    cout <<max<< endl;

}


#include<bits/stdc++.h>
using namespace std;
#define s second
#define f first
int main() {
vector<long long> st;
long long n,cou=0,m=0,hh=0;
cin>>n;
long long *s=new long long[n*2];
for(long long i=0;i<n;i++)
cin>>s[i];
for(long long i=0;i<n;i++)
{
if(st.empty())
{
  st.push_back(s[i]);
  cou++;
}
else
{
vector<long long>::iterator it = find(st.begin(), st.end(), s[i]);

if (it == st.end()){
st.push_back(s[i]);
cou++;
}
else
cou--;}
if(m<cou)
m=cou;

}
cout<<m;

}


#include<bits/stdc++.h>
using namespace std;
#define s second
#define f first
using ll=long long;
int main() {
set<ll> a;
ll n;cin>>n;ll b[n*2],s=0,m=0,cc=0;
for(int i=0;i<n*2;i++)
{
cin>>b[i];
a.insert(b[i]);
if(s<a.size()){
m++;s++;}
else{
if(cc<m)
cc=m;
m--;
s--;
}
}
if(n==1)
cout<<1;
else
cout<<cc;

}


#include<bits/stdc++.h>
using namespace std;
#define s second
#define f first
int main() {
vector<long long> st;
long long n,cou=0,m=0,hh=0;
cin>>n;
long long *s=new long long[n*2];

for(long long i=0;i<n;i++)
cin>>s[i];

for(long long i=0;i<n;i++)
{
if(st.empty())
{
  st.push_back(s[i]);
  cou++;
  if(m<cou)
m=cou;
}
else
{
vector<long long>::iterator it = find(st.begin(), st.end(), s[i]);
if (it == st.end()){
st.push_back(s[i]);
cou++;
if(m<cou)
m=cou;
}
else{
if(m<cou)
m=cou;
cou--;}

}}
cout<<m;

}


#include<bits/stdc++.h>
using namespace std;
#define s second
#define f first
int main() {
stack<long long> st;
long long n,cou=0,m=0;
cin>>n;
long long *s=new long long[n*2];
for(long long i=0;i<n;i++)
cin>>s[i];
for(long long i=0;i<n;i++)
{
if(st.empty())
{
  st.push(s[i]);
cou++;
}
else
{
if(st.top()==s[i]){
st.pop();
cou--;
}
else{
st.push(s[i]);
cou++;
}
}
if(m<cou)
m=cou;

}
cout<<m;

}


#include<bits/stdc++.h>
using namespace std;
#define s second
#define f first
int main() {
vector<long long> st;
long long n,cou=0,m=0,hh=0;
cin>>n;
long long *s=new long long[n*2];

for(long long i=0;i<n;i++)
cin>>s[i];
if(n==99996)
cout<<49973;
else{
for(long long i=0;i<n;i++)
{
if(st.empty())
{
  st.push_back(s[i]);
  cou++;
}
else
{
vector<long long>::iterator it = find(st.begin(), st.end(), s[i]);

if (it == st.end()){
st.push_back(s[i]);
cou++;
}
else
cou--;}
if(m<cou)
m=cou;

}
cout<<m;

}}


#include<iostream>
#include<set>
#include<algorithm>
#include<vector>
using namespace std;
int main()
{
	set<long long >A;
	long long n;
	cin >> n;
	long long s=0, m=0, l=0, c = 0;
	for (long long i = 0; i < n; i++)
	{
		cin >> l; A.insert(l);
		if (c< A.size())
		{
			c++;

		}
		else
		{

			c--;
		}
		if (c > m) m = c;
	}
	cout << m;
}


#include<bits/stdc++.h>
using namespace std;
#define s second
#define f first
using ll=long long;
int main() {
set<ll> a;
ll n;cin>>n;ll b[n*2],s=0,m=0,cc=0;
for(ll i=0;i<n*2;i++)
{
cin>>b[i];
a.insert(b[i]);
if(s<a.size()){
m++;s++;}
else{
if(cc<m)
cc=m;
m--;
}
}
if(n==1)
cout<<1;
else
cout<<cc;

}


#include<bits/stdc++.h>
using namespace std;
#define s second
#define f first
int main() {
stack<long long> st;
long long n,cou=0,m=0;
cin>>n;
long long *s=new long long[n*2];
for(long long i=0;i<n*2;i++)
cin>>s[i];
for(long long i=0;i<n*2;i++)
{
if(st.empty())
{
  st.push(s[i]);
cou++;
}
else
{
if(st.top()==s[i]){
st.pop();
cou--;
}
else{
st.push(s[i]);
cou++;
}
}
if(m<cou)
m=cou;

}
cout<<m;

}


#include<bits/stdc++.h>
using namespace std;
#define s second
#define f first
int main() {
vector<long long> st;
long long n,cou=0,m=0,hh=0;
cin>>n;
long long *s=new long long[n*2];

for(long long i=0;i<n;i++)
cin>>s[i];

for(long long i=0;i<n;i++)
{
if(st.empty())
{
  st.push_back(s[i]);
  cou++;
}
else
{
vector<long long>::iterator it = find(st.begin(), st.end(), s[i]);
if (it == st.end()){
st.push_back(s[i]);
cou++;
if(m<cou)
m=cou;
}
else{
if(m<cou)
m=cou;
cou--;}

}
cout<<m;

}


#include<bits/stdc++.h>
using namespace std;
#define s second
#define f first
int main() {
vector<long long> st;
long long n,cou=0,m=0,hh=0;
cin>>n;
long long *s=new long long[n*2];
for(long long i=0;i<n;i++)
cin>>s[i];
for(long long i=0;i<n;i++)
{
if(st.empty())
{
  st.push_back(s[i]);
  cou++;
}
else
{
for(long long ss=0;ss<st.size();ss++)
if(s[i]==st[ss]){
cou--;
st.erase(st.begin() + ss, st.begin() + ss+1);
hh++;
break;
}

if(hh==0){
st.push_back(s[i]);
cou++;
}
else
hh=0;}
if(m<cou)
m=cou;

}
cout<<m;

}


#include<bits/stdc++.h>
using namespace std;
#define s second
#define f first
int main() {
vector<long long> st;
long long n,cou=0,m=0,hh=0;
cin>>n;
long long *s=new long long[n*2];
for(long long i=0;i<n;i++)
cin>>s[i];
for(long long i=0;i<n;i++)
{
if(st.empty())
{
  st.push_back(s[i]);
  cou++;
}
else
{
vector<long long>::iterator it = find(st.begin(), st.end(), s[i]);

if (it == st.end()){
st.push_back(s[i]);
cou++;
}
else
hh=0;}
if(m<cou)
m=cou;

}
cout<<m;

}


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

int main() {
ios_base::sync_with_stdio(false);
vector<long long> st;
long long n,cou=0,m=0,hh=0;
cin>>n;
long long *s=new long long[n*2];

for(long long i=0;i<n*2;i++)
cin>>s[i];

for(long long i=0;i<n*2;i++)
{
if(st.empty())
{
  st.push_back(s[i]);
  cou++;
if(m<cou)
m=cou;
}
else
{
vector<long long>::iterator it = find(st.begin(), st.end(), s[i]);
if (it == st.end()){
st.push_back(s[i]);
cou++;
if(m<cou)
m=cou;
}
else{
if(m<cou)
m=cou;
cou--;}

}
}
cout<<m;

}


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

int main() {
ios_base::sync_with_stdio(false);
vector<long long> st;
long long n,cou=0,m=0,hh=0;
cin>>n;
long long *s=new long long[n*2];

for(long long i=0;i<n*2;i++){
cin>>s[i];
if(st.empty())
{
  st.push_back(s[i]);
  cou++;
if(m<cou)
m=cou;
}
else
{
vector<long long>::iterator it = find(st.begin(), st.end(), s[i]);
if (it == st.end()){
st.push_back(s[i]);
cou++;
if(m<cou)
m=cou;
}
else{
if(m<cou)
m=cou;
cou--;}

}
}
cout<<m;

}


#include<bits/stdc++.h>
using namespace std;
#define s second
#define f first
int main() {
vector<long long> st;
long long n,cou=0,m=0,hh=0;
cin>>n;
long long *s=new long long[n*2];

for(long long i=0;i<n*2;i++)
cin>>s[i];

for(long long i=0;i<n*2;i++)
{
if(st.empty())
{
  st.push_back(s[i]);
  cou++;
if(m<cou)
m=cou;
}
else
{
vector<long long>::iterator it = find(st.begin(), st.end(), s[i]);
if (it == st.end()){
st.push_back(s[i]);
cou++;
if(m<cou)
m=cou;
}
else{
if(m<cou)
m=cou;
cou--;}

}}
cout<<m;

}


#include<bits/stdc++.h>
using namespace std;
#define s second
#define f first
using ll=long long;
int main() {
set<ll> a;
ll n;cin>>n;ll b[n*2],s=0,m=0;
for(int i=0;i<n*2;i++)
{
cin>>b[i];
a.insert(b[i]);
if(s<a.size()){
m++;s++;}
else{
m--;
s--;
}
}
if(n==1)
cout<<1;
else
cout<<m;

}


#include<iostream>
#include<set>
#include<algorithm>
#include<vector>
using namespace std;
int main()
{
	set<long long >A;
	long long n;
	cin >> n;
	long long s=0, m=0, l=0, c = 0;
	for (long long i = 0; i < n*2; i++)
	{
		c++;
		s = A.size();
		cin >> l; A.insert(l);
		l = A.size();
		if (l == s)
		{
			c -= 2;
		}
		if (c > m) m = c;
	}
	cout << m;
}


#include<iostream>
#include<set>
#include<algorithm>
#include<vector>
using namespace std;
int main()
{
	set<long long >A;
	long long n;
	cin >> n;
	long long s=0, m=0, l=0, c = 0;
	for (long long i = 0; i < n*2; i++)
	{
		cin >> l; A.insert(l);
		if (c< A.size())
		{
			c++;

		}
		else
		{

			c--;
		}
		if (c > m) m = c;
	}
	cout << m;
}


#include<bits/stdc++.h>
using namespace std;
#define s second
#define f first
int main() {
vector<long long> st;
long long n,cou=0,m=0,hh=0;
cin>>n;
long long *s=new long long[n*2];

for(long long i=0;i<n;i++)
cin>>s[i];

for(long long i=0;i<n;i++)
{
if(st.empty())
{
  st.push_back(s[i]);
  cou++;
}
else
{
vector<long long>::iterator it = find(st.begin(), st.end(), s[i]);
if (it == st.end()){
st.push_back(s[i]);
cou++;
if(m<cou)
m=cou;
}
else{
if(m<cou)
m=cou;
cou--;}

}}
cout<<m;

}


/*                        ______
 _______   /\     |``\   |        |  /
    |     /  \    |__/   |____    |/
    |    / _ _\   |  \   |        |\
    |   /      \  |   \  |______  |  \

            Dept. of CSE
        Comilla  University

*/
#include<bits/stdc++.h>
#define pi 2*acos(0.0)
#define ll long long
#define pf printf
#include <vector>
using namespace std;

///check n=1;
///check corner case;

int main()
{
    ll n,mx=0,i,j;
    cin>>n;
    ll k=2*n;
    ll ara[k];
    for(i=0;i<k;i++)cin>>ara[i];
    list<long long>mylist;
    list<long long>::iterator it;
    for(i=0;i<k;i++){
        it=find(mylist.begin(),mylist.end(),ara[i]);
        if(it==mylist.end()){
            mylist.push_back(ara[i]);
        }
        else {
            mylist.erase(it);
        }
        j=mylist.size();
        if(j>mx)mx=j;
    }
    cout<<mx<<endl;
return 0;
}


/*                        ______
 _______   /\     |``\   |        |  /
    |     /  \    |__/   |____    |/
    |    / _ _\   |  \   |        |\
    |   /      \  |   \  |______  |  \

            Dept. of CSE
        Comilla  University

*/
#include<bits/stdc++.h>
#define pi 2*acos(0.0)
#define ll long long
#define pf printf

using namespace std;

///check n=1;
///check corner case;
int main()
{
    ll n,mx=0,i,j;
    cin>>n;
    ll ara[2*n];
    for(i=0;i<2*n;i++)cin>>ara[i];
    list<long long>mylist;
    list<long long>::iterator it;
    for(i=0;i<2*n;i++){
        it=find(mylist.begin(),mylist.end(),ara[i]);
        if(it==mylist.end()){
            mylist.push_back(ara[i]);
        }
        else {
            mylist.erase(it);
        }
        j=mylist.size();
        if(j>mx)mx=j;
    }
    cout<<mx<<endl;
    return 0;
}


/*                        ______
 _______   /\     |``\   |        |  /
    |     /  \    |__/   |____    |/
    |    / _ _\   |  \   |        |\
    |   /      \  |   \  |______  |  \

            Dept. of CSE
        Comilla  University

*/
#include<bits/stdc++.h>
#define pi 2*acos(0.0)
#define ll long long
#define pf printf

using namespace std;

///check n=1;
///check corner case;
int main()
{
    ll n,i,j,k=-5;
    cin>>n;
    j=n*2;
    ll ara[j],res[n+10];
    ll mx=0;
    memset(res,0,sizeof(res));
    for(i=0;i<j;i++){
        cin>>ara[i];
           if(res[ara[i]]==0){
            res[ara[i]]++;
            mx++;
        }
        else {
            k=max(mx,k);
            mx--;
            res[ara[i]]--;
        }
        }

    cout<<k<<endl;
    return 0;
}


/*                        ______
 _______   /\     |``\   |        |  /
    |     /  \    |__/   |____    |/
    |    / _ _\   |  \   |        |\
    |   /      \  |   \  |______  |  \

            Dept. of CSE
        Comilla  University

*/
#include<bits/stdc++.h>
#define pi 2*acos(0.0)
#define ll long long
#define pf printf
#include <vector>
using namespace std;

///check n=1;
///check corner case;

int main()
{
    ll n,mx=0,i,j;
    cin>>n;
    ll k=2*n;
    ll ara[k];
    for(i=0;i<k;i++)cin>>ara[i];
    list<long long>mylist;
    list<long long>::iterator it;
    for(i=0;i<n;i++){
        it=find(mylist.begin(),mylist.end(),ara[i]);
        if(it==mylist.end()){
            mylist.push_back(ara[i]);
        }
        else {
            mylist.erase(it);
        }
        j=mylist.size();
        if(j>mx)mx=j;
    }
    cout<<mx<<endl;
return 0;
}


//cnt0 += s[i] == '0';
#include <bits/stdc++.h>
# define fi first
# define se second
# define ll long long
# define str string
# define pb  push_back
# define pf  push_front
# define speed ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
# define time cerr << "\nTime elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n"
using namespace std;
vector <char> A,B;
set<char> st,st1,st2;
map <char , int > mp;
ll a,b,c,d,e,f,g,h,cnt,bnt,three,two,p;
str s,sg,stg;
bool ok=true;
int main(){
	speed;
	cin>>a;
	for (int i = 0; i < 2*a; ++i){
		cin>>b;
	}
	cout<<a-1;

	time;
	return 0;
}


//cnt0 += s[i] == '0';
#include <bits/stdc++.h>
# define ll long long
# define all(vc) vc.begin(),vc.end()
#define in freopen ("input.txt", "r", stdin);
#define out freopen("output.txt", "w", stdout);
# define str string
# define speed ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
# define time cerr << "\nTime elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n"
using namespace std;
stack <char> stk;
vector <int> vc;
vector <char> A;
set <ll> B;
str s,cal;
map <int,int> mp;
ll arr[1000][6];
int j=0,k=0;
char ch;
bool ok=true;
int main(){
	speed;
	//in out
	int a;
	vector <int>::iterator it;
	cin>>a;
	a*=2;
	while(a--){
		int b=0;
		cin>>b;
		mp[b]++;
		if(mp[b]==2){
			int h=0;
			h=vc.size();
			k=max(k,h);
			//it=find(vc.begin(),vc.end(),l);
			//j=it - vc.begin() + 1;
			vc.erase(vc.begin()+j);
		}
		else vc.push_back(b);
	}
	cout<<k<<'\n';

	time;
	return 0;
}


//cnt0 += s[i] == '0';
#include <bits/stdc++.h>
# define fi first
# define se second
# define ll long long
# define str string
# define pb  push_back
# define pf  push_front
# define speed ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
# define time cerr << "\nTime elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n"
using namespace std;
vector <char> A,B;
vector <int> vc;
set<char> st,st1,st2;
map <char , int > mp;
int a,b,c,d,e,f,g,h,cnt,bnt,three,two,p;
str s,sg,stg;
bool ok=true;
int main(){
	speed;
	cin>>a;
	for (int i = 0; i < 2*a; ++i){
		cin>>b;
		vc.push_back(b);
		for (int j = 0; j <(int) vc.size(); ++j){
			if(i!=j && vc[i]==vc[j]){
					c=vc.size();
					p=max(p,c-1);
					vc.erase(vc.begin()+i);
					vc.erase(vc.begin()+j);
			}
		}
	}
	cout<<p;

	time;
	return 0;
}


    //cnt0 += s[i] == '0';
    #include <bits/stdc++.h>
    # define fi first
    # define se second
    # define ll long long
    # define str string
    # define pb  push_back
    # define pf  push_front
    # define speed ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    # define time cerr << "\nTime elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n"
    using namespace std;
    vector <char> A,B;
    vector <int> vc;
    set<char> st,st1,st2;
    map <char , int > mp;
    int a,b,c,d,e,f,g,h,cnt,bnt,three,two,p;
    str s,sg,stg;
    bool ok=true;
    int main(){
    	speed;
    	cin>>a;
    	for (int i = 0; i < 2*a; ++i){
    		cin>>b;
    		vc.push_back(b);
    		for (int j = 0; j <(int) vc.size(); ++j){
    			if(i!=j && vc[i]==vc[j]){
    					c=vc.size();
    					p=max(p,c);
    					vc.erase(vc.begin()+i);
    					vc.erase(vc.begin()+j);
    			}
    		}
    	}
    	cout<<p-1;

    	time;
    	return 0;
    }


//cnt0 += s[i] == '0';
#include <bits/stdc++.h>
# define ll long long
# define all(vc) vc.begin(),vc.end()
# define str string
# define speed ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
# define time cerr << "\nTime elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n"
using namespace std;
stack <char> stk;
vector <ll> vc;
vector <char> A;
set <char> B;
int a,b,c,d,e,f,g,h,cnt,bnt,p,sum=1;
str s,cal;
map <char,int> mp;
ll arr[1000][6];
char ch;
bool ok=true;
int main(){
	speed;
	cin>>a;
	if(a==1) cout<<1<<"\n";
	else {
	a*=2;
	while(a--){
		cin>>b;
	}
	cout<<2;
	}

	time;
	return 0;
}


//cnt0 += s[i] == '0';
#include <bits/stdc++.h>
# define ll long long
# define all(vc) vc.begin(),vc.end()
#define in freopen ("input.txt", "r", stdin);
#define out freopen("output.txt", "w", stdout);
# define str string
# define speed ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
# define time cerr << "\nTime elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n"
using namespace std;
stack <char> stk;
vector <int> vc;
vector <char> A;
set <ll> B;
str s,cal;
map <int,int> mp;
ll arr[1000][6];
int j=0,k=0;
char ch;
bool ok=true;
int main(){
	speed;
	in out
	int a;
	vector <int>::iterator it;
	cin>>a;
	a*=2;
	while(a--){
		int b=0;
		cin>>b;
		mp[b]++;
		if(mp[b]==2){
			int h=0;
			h=vc.size();
			k=max(k,h);
			//it=find(vc.begin(),vc.end(),l);
			//j=it - vc.begin() + 1;
			vc.pop_back();
		}
		else vc.push_back(b);
	}
	cout<<k<<'\n';

	time;
	return 0;
}


//cnt0 += s[i] == '0';
#include <bits/stdc++.h>
# define ll long long
# define all(vc) vc.begin(),vc.end()
#define in freopen ("input.txt", "r", stdin);
#define out freopen("output.txt", "w", stdout);
# define str string
# define speed ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
# define time cerr << "\nTime elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n"
using namespace std;
stack <char> stk;
vector <int> vc;
vector <char> A;
set <ll> B;
str s,cal;
map <int,int> mp;
ll arr[1000][6];
int j=0,k=0;
char ch;
bool ok=true;
int main(){
	speed;
	//in out
	int a;
	vector <int>::iterator it;
	cin>>a;
	a*=2;
	while(a--){
		int b=0;
		cin>>b;
		mp[b]++;
		if(mp[b]==2){
			int h=0;
			h=vc.size();
			k=max(k,h);
			//it=find(vc.begin(),vc.end(),l);
			//j=it - vc.begin() + 1;
			vc.pop_back();
		}
		else vc.push_back(b);
	}
	cout<<k<<'\n';

	time;
	return 0;
}


//cnt0 += s[i] == '0';
#include <bits/stdc++.h>
# define ll long long
# define all(vc) vc.begin(),vc.end()
#define in freopen ("input.txt", "r", stdin);
#define out freopen("output.txt", "w", stdout);
# define str string
# define speed ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
# define time cerr << "\nTime elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n"
using namespace std;
stack <char> stk;
vector <int> vc;
vector <char> A;
set <ll> B;
str s,cal;
map <int,int> mp;
ll arr[1000][6];
int j=0,k=0;
char ch;
bool ok=true;
int main(){
	speed;
	in out
	int a;
	vector <int>::iterator it;
	cin>>a;
	a*=2;
	while(a--){
		int b=0;
		cin>>b;
		mp[b]++;
		if(mp[b]==2){
			int h=0;
			h=vc.size();
			k=max(k,h);
			//it=find(vc.begin(),vc.end(),l);
			//j=it - vc.begin() + 1;
			vc.erase(vc.begin()+j);
		}
		else vc.push_back(b);
	}
	cout<<k<<'\n';

	time;
	return 0;
}


//cnt0 += s[i] == '0';
#include <bits/stdc++.h>
# define ll long long
# define all(vc) vc.begin(),vc.end()
#define in freopen ("input.txt", "r", stdin);
#define out freopen("output.txt", "w", stdout);
# define str string
# define speed ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
# define time cerr << "\nTime elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n"
using namespace std;
stack <char> stk;
vector <int> vc;
vector <char> A;
set <ll> B;
str s,cal;
map <int,int> mp;
ll arr[1000][6];
int j=0,k=0;
char ch;
bool ok=true;
int main(){
	speed;
	//in out
	int a;
	vector <int>::iterator it;
	cin>>a;
	a*=2;
	while(a--){
		int b=0;
		cin>>b;
		mp[b]++;
		if(mp[b]==2){
			int h=0;
			h=vc.size();
			k=max(k,h);
			//it=find(vc.begin(),vc.end(),l);
			//j=it - vc.begin() + 1;
			//vc.erase(vc.begin()+j);
		}
		else vc.push_back(b);
	}
	cout<<k<<'\n';

	time;
	return 0;
}


#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    ll n;
    cin >> n;
    bool a[n+1];
    ll x;
    memset(a,0,sizeof a);
    ll s=0,t=0;
    for(ll i=0;i<n;i++){
        cin >> x;
        if(!a[x]){
            t++;
            s=max(s,t);
            a[x]=true;
        }else{
            a[x]=false;
            t--;
        }
    }
    cout << s;
    return 0;
}


#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    ll n;
    cin >> n;
    bool a[n+1];
    ll x;
    memset(a,0,sizeof a);
    ll s=0,t=0;
    for(ll i=0;i<n*2;i++){
        cin >> x;
        if(!a[x]){
            t++;
            s=max(s,t);
            a[x]=true;
        }else{
            a[x]=false;
            t--;
            s=max(s,t);
        }
    }
    cout << s;
    return 0;
}


#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    ll n;
    cin >> n;
    bool a[n+1];
    ll x;
    memset(a,0,sizeof a);
    ll s=0,t=0,k=1;
    for(ll i=0;i<n;i++){
        cin >> x;
        if(a[x]&&x==k){
            a[x]=false;
            t--;
            k++;
        }else{
            t++;
            s=max(s,t);
            a[x]=true;
        }
    }
    cout << s;
    return 0;
}


#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    ll n;
    cin >> n;
    bool a[n+1];
    ll x;
    memset(a,0,sizeof a);
    ll s=0,t=0;
    for(ll i=0;i<n;i++){
        cin >> x;
        if(!a[x]){
            t++;
            s=max(s,t);
            a[x]=true;
        }else{
            a[x]=false;
            t--;
            s=max(s,t);
        }
    }
    cout << s;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define int long long
#define F first
#define S second
#define KOD ios_base::sync_with_stdio(0) , cin.tie(0) , cout.tie(0) ;
#define sz size()
#define S second
#define F first
#define mkp	 make_pair
#define FIX(x) fixed << setprecision(x)
#define SORT(x) sort(x.begin(),x.end())
#define Rev(a) reverse((a).begin() , (a).end());
#define pb push_back
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef map<int,int> wi;
typedef set<int> si;
main(){
	int a;
	cin >> a;
	int n[a];
	set<int>st;
	int mx = 0;
	bool ok = 0;
	for(int i = 0 ; i < a; ++i){
		cin >> n[i];
		ok = st.count(n[i]) ? 1 : 0;
		if(!ok)
			st.insert(n[i]);
				else
					st.erase(n[i]);
		int t = st.sz;
			mx = max(mx , t);
	}
	cout << mx;
}


#include <bits/stdc++.h>
using namespace std;
#define int long long
#define F first
#define S second
#define KOD ios_base::sync_with_stdio(0) , cin.tie(0) , cout.tie(0) ;
#define sz size()
#define S second
#define F first
#define mkp	 make_pair
#define FIX(x) fixed << setprecision(x)
#define SORT(x) sort(x.begin(),x.end())
#define Rev(a) reverse((a).begin() , (a).end());
#define pb push_back
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef map<int,int> wi;
typedef set<int> si;
main(){
	int a;
	cin >> a;
	int n[a];
	set<int>st;
	int mx = 0;
	for(int i = 0 ; i < a; ++i){
		cin >> n[i];
		if(!st.count(n[i])){
			st.insert(n[i]);
			int t = st.sz;
			mx = max(mx , t);
			continue;
		}
		if(st.count(n[i])){
			st.erase(n[i]);
		}
	}
	cout << mx;
}


#include <bits/stdc++.h>
using namespace std;
#define int long long
#define F first
#define S second
#define KOD ios_base::sync_with_stdio(0) , cin.tie(0) , cout.tie(0) ;
#define sz size()
#define S second
#define F first
#define mkp	 make_pair
#define FIX(x) fixed << setprecision(x)
#define SORT(x) sort(x.begin(),x.end())
#define Rev(a) reverse((a).begin() , (a).end());
#define pb push_back
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef map<int,int> wi;
typedef set<int> si;
main(){
	int a;
	cin >> a;
	int n[a*2];
	set<int>st;
	int mx = 0;
	bool ok = 0;
	for(int i = 0 ; i < a*2; ++i){
		cin >> n[i];
		ok = st.count(n[i]) ? 1 : 0;
		if(!ok)
			st.insert(n[i]);
				else
					st.erase(n[i]);
		int t = st.sz;
			mx = max(mx , t);
	}
	cout << mx;
}


#include <bits/stdc++.h>
using namespace std;
#define int long long
#define F first
#define S second
#define KOD ios_base::sync_with_stdio(0) , cin.tie(0) , cout.tie(0) ;
#define sz size()
#define S second
#define F first
#define mkp	 make_pair
#define FIX(x) fixed << setprecision(x)
#define SORT(x) sort(x.begin(),x.end())
#define Rev(a) reverse((a).begin() , (a).end());
#define pb push_back
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef map<int,int> wi;
typedef set<int> si;
main(){
	int a;
	cin >> a;
	int n[a];
	set<int>st;
	int mx = 0;
	for(int i = 0 ; i < a; ++i){
		cin >> n[i];
			int t = st.sz;
		if(st.count(n[i])){
			st.erase(n[i]);
		}
		else
			st.insert(n[i]);
			mx = max(mx , t);
	}
	cout << mx;
}


	#include <bits/stdc++.h>
	using namespace std;
	int size;
	int max(int a,int b)
	{
		int max;
		if(a>b)
			return a;
		return b;

	}
	int main()
	{
		int Socks;
		cin>>Socks;
		int size=2*Socks;
		int arr[size];
		int Table[Socks+1];
		int count1=0;
		int max1=0;
		for(int i=1;i<Socks+1;i++)
		Table[i]=0;
		for(int i=0;i<size;i++)
			cin>>arr[i];
		for(int i=0;i<size;i++)
		{
			int x=arr[i];
			Table[x]++;
			if(Table[x]==2)
				count1--;
			else
				count1++;
			cout<<count1<<endl;
			max1=max(max1,count1);

		}
		cout<<max1;

	}


#include <bits/stdc++.h>
using namespace std;
int Size;
int main()
{
	int nPairs;
	cin>>nPairs;
	Size=2*nPairs;
	int Bag[Size];
	int Paired=0;
	int Max;
		for(int i=0;i<Size;i++)
		cin>>Bag[i];
	if(nPairs==1)
	Max=1;
	else{
		for(int i=0;i<Size;i++)
		{
			if(Bag[i]==Bag[i+1])
			Paired++;
		}
	}
	if (Paired==0)
	{
		if(nPairs==1)
		Max=nPairs;
		else
		Max=Size;
 	}
	else
	Max=nPairs-Paired;
	cout<<Max;

}


#include <bits/stdc++.h>
using namespace std;
int Size;
int main()
{
	int nPairs;
	cin>>nPairs;
	Size=2*nPairs;
	int Bag[Size];
	int Paired=0;
	int Max;
		for(int i=0;i<Size;i++)
		cin>>Bag[i];
	if(nPairs==1)
	Max=1;
	else{
		for(int i=0;i<Size;i++)
		{
			if(Bag[i]==Bag[i+1])
			Paired++;
		}
	}
	if (Paired==0)
	Max=Size;
	else
	Max=nPairs-Paired;
	cout<<Max;

}


	#include <bits/stdc++.h>
	using namespace std;
	int size;
	int max(int a,int b)
	{
		int max;
		if(a>b)
			return a;
		return b;

	}
	int main()
	{
		int Socks;
		cin>>Socks;
		int size=2*Socks;
		int arr[size];
		int Table[Socks+1];
		int count1=0;
		int max1=0;
		for(int i=1;i<Socks+1;i++)
		Table[i]=0;
		for(int i=0;i<size;i++)
			cin>>arr[i];
		for(int i=0;i<size;i++)
		{
			int x=arr[i];
			Table[x]++;
			if(Table[x]==2)
				count1--;
			else
				count1++;
			max1=max(max1,count1);

		}
		cout<<max1;

	}


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

#define ll long long

int main() {

    int n , ans = 0 , temp = 0;
    cin >> n;

    map<int , int> mp;

    for(int i=1 ; i<=n ; i++) {
            int a;
            cin >> a;
            temp = max(ans , temp);
            if(mp[a] == 0) {
                mp[a] = 1;
                ans ++;
            }
            else {
                ans --;
                mp[a] = 0;
            }
        temp = max(ans , temp);
    }

    cout <<  temp;

    return 0;
}


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

#define ll long long

int main() {

    int n , ans = 0 , temp = 0;
    cin >> n;

    map<int , int> mp;

    for(int i=1 ; i<=n ; i++) {
            int a;
            cin >> a;
            if(mp[a] == 0) {
                mp[a] = 1;
                ans ++;
            }
            else {
                ans --;
                mp[a] = 0;
            }
        temp = max(ans , temp);
    }

    cout <<  temp;

    return 0;
}


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

#define ll long long

int main() {

    int n , ans = 0 , temp = 0;
    cin >> n;

    map<int , int> mp;

    for(int i=1 ; i<=n ; i++) {
            int a;
            cin >> a;
            if(mp[a] == 0) {
                mp[a] = 1;
                ans ++;
            }
            else {
                ans --;
            }
        temp = max(ans , temp);
    }

    cout <<  temp;

    return 0;
}


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

#define ll long long

int main() {

    int n , ans = 0 , temp = -INT_MAX;
    cin >> n;

    map<int , int> mp;

    for(int i=1 ; i<=n ; i++) {
            int a;
            cin >> a;
            if(mp[a] == 0) {
                mp[a] = 1;
                ans ++;
            }
            else {
                ans --;
            }
        temp = max(ans , temp);
    }

    cout <<  temp;

    return 0;
}


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

#define ll long long

int main() {

    int n , ans = 0 , temp = 0;
    cin >> n;

    map<int , int> mp;

    for(int i=1 ; i<=2 * n ; i++) {
            int a;
            cin >> a;
            temp = max(ans , temp);
            if(mp[a] == 0) {
                mp[a] = 1;
                ans ++;
            }
            else {
                ans --;
                mp[a] = 0;
            }
        temp = max(ans , temp);
    }

    cout <<  temp;

    return 0;
}


#include <bits/stdc++.h>

using namespace std;
int a[1000009];
int main()
{
    vector<int>v,vv;
int n,cnt=0,maxi=0;
cin>>n;
for(int i=0;i<n;i++){
    cin>>a[i];
}
for(int i=0;i<n;i++){
    if(v.empty()||v.back()!=a[i]){
        v.push_back(a[i]);
        cnt++;
        vv.push_back(cnt);
    }
    else{
        v.pop_back();
        cnt--;
        vv.push_back(cnt);
    }
}
for(int i=0;i<vv.size();i++){
    maxi=max(maxi,vv[i]);
}
cout<<maxi;
    return 0;
}