#pragma GCC optimize ("O2")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
//#include<atcoder/all>
//using namespace atcoder;
#include<iostream>
#include<cstring>

using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int CM = 1 << 17, CL = 12;
char cn[CM + CL], * ci = cn + CM + CL, * owa = cn + CM, ct;
const ll ma0 = 1157442765409226768;
const ll ma1 = 1085102592571150095;
const ll ma2 = 71777214294589695;
const ll ma3 = 281470681808895;
const ll ma4 = 4294967295;
inline int getint() {
	if (ci - owa > 0) {
		memcpy(cn, owa, CL);
		ci -= CM;
		fread(cn + CL, 1, CM, stdin);
	}
	ll tmp = *(ll*)ci;
	int dig = 68 - __builtin_ctzll((tmp & ma0) ^ ma0);
	tmp = tmp << dig & ma1;
	tmp = tmp * 10 + (tmp >> 8) & ma2;
	tmp = tmp * 100 + (tmp >> 16) & ma3;
	tmp = tmp * 10000 + (tmp >> 32) & ma4;
	ci += 72 - dig >> 3;
	return tmp;
}

int A[100001], B[100001];
ll kotae = 0;
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);


	int N = getint();
	rep(i, N) A[getint()]++;
	rep1(i, N) B[i] = A[getint()];
	rep(i, N) kotae += B[getint()];

	co(kotae);

	Would you please return 0;
}
#include <algorithm>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <cmath>
#include <iterator>
#include <queue>
#define ll long long int
using namespace std;

int main()
{
  ll n,q;
  cin>>n>>q;
  vector<ll> a(n);
  for(ll i = 0; i < n; i++){
    cin>>a[i];
  }
  ll ans;
  for(ll i = 0; i < q; i++){
    ll num;
    cin>>num;
    ll ans;
    if(num >= a[n-1]){
      ans = num + n;
    }else{
      auto iter = lower_bound(a.begin(),a.end(),num);
      num += distance(a.begin(),iter);
      for(auto iter2 = iter; iter2 != a.end(); iter2++){
        if(num < *iter2){
          ans = num;
          break;
        }else{
          num++;
          ans = num;
        }
      }
    }
    cout<<ans<<endl;
  }
  return 0;
};