#include <bits/stdc++.h>
using namespace std;
int n, m, k;
int a[100100], b[100100], f[100100];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> m >> k;
  int M = m;
  int p = 0;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    b[a[i]] = i;
    f[a[i]] = p;
    if (i % k == 0) p++;
  }
  long long sol = 0;
  while (m--) {
    int x;
    cin >> x;
    sol += f[x];
    int loc = b[x];
    if (loc != 1) {
      b[x]--;
      int temp = a[loc - 1];
      b[a[loc - 1]]++;
      a[loc - 1] = x;
      a[loc] = temp;
      if (b[x] % k == 0) {
        f[x]--;
        f[temp]++;
      }
    }
  }
  cout << sol + M;
  return 0;
}
