#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define str to_string
#define endl "\n"
#define PI 3.141592653589
using namespace std;
using lint = long long;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

int main(){
    int n,m;cin>>n;
    string s;
    map<string,int> dic;
    for(int i=0;i<n;i++){
        cin>>s;
        dic[s]++;
    }
    cin>>m;
    for(int i=0;i<m;i++){
        cin>>s;
        dic[s]--;
    }
    int ans=0;
    for(auto p:dic){
        auto v=p.second;
        if(v>ans)ans=v;
    }
    cout<<ans<<endl;
}

#include <bits/stdc++.h>
#include <string>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define ll long long

int main() {
	int n, k;

	cin >> n >> k;
	vector<int> x(n);
	rep(i, n)
		cin >> x[i];

	int ans=INT_MAX;
	for (int i = 0;i < n - k + 1;++i) {
		int l = x[i];
		int r = x[i + k - 1];
		int m = min(abs(l), abs(r)) + abs(l - r);
		ans = min(ans, m);
	}

	cout << ans << endl;
}