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

bool linearSearch(const vector<int>& ary, int key) {
    for (auto i = 0; i < ary.size(); i++) {
        if (ary[i] == key) {
            return true;
        }
    }
    return false;
}

int main(void) {
    int n;
    cin >> n;
    vector<int> S(n);
    for (int i = 0; i < n; i++) {
        cin >> S[i];
    }
    int q;
    cin >> q;

    int cnt = 0;
    for (int i = 0; i < q; i++) {
        int key;
        cin >> key;

        if (linearSearch(S, key)) cnt++;
    }

    cout << cnt << endl;
    return 0;
}
#include <bits/stdc++.h>
#pragma GCC optimize("O3")

#define fi first
#define se second
#define em emplace
#define eb emplace_back
#define mp make_pair
#define pi pair<int,int>
#define vi vector<int>
#define vpi vector<pair<int,int>>
#define vll vector<ll>
#define vpll vector<pair<ll,ll>>
#define endl '\n'

#define si(v) int((v).size())
#define all(v) (v).begin(), (v).end()
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i) 
#define rep2(i, n, m) for (ll i = n; i <= (ll)(m); ++i)
#define rep3(i, n, m) for (ll i = n; i >= (ll)(m); --i)

template<class T, class U> bool chmax(T &a, U b) { if (a < b) a = b; return true; }
template<class T, class U> bool chmin(T &a, U b) { if (a > b) a = b; return true; }

using ll = long long;
using ld = long double;
using namespace std;

constexpr ll MOD = 1000000007;

signed main()
{
  cout << fixed << setprecision(20);
  ios::sync_with_stdio(false);
  cin.tie(0);

  vi d(3);
  rep(i, 3) cin >> d[i];

  int k; cin >> k;
  sort(all(d));

  rep(i, k) d[2] *= 2;

  cout << accumulate(all(d),0) << endl;

  return (0);
}
