#include <bits/stdc++.h>
using namespace std;
const int MAX = int(1e5) + 1;
int section[MAX];
int location[MAX];
int config[MAX];
int main() {
  int n, m, k;
  scanf("%d", &n);
  scanf("%d", &m);
  scanf("%d", &k);
  for (int i = 0, s = 0; i < n; i++) {
    if (i % k == 0) s++;
    scanf("%d", &config[i]);
    location[config[i]] = i;
    section[config[i]] = s;
  }
  long long int ans = 0;
  for (int i = 0; i < m; i++) {
    int in;
    scanf("%d", &in);
    ans += section[in];
    if (location[in] == 0) continue;
    if (location[in] % k == 0) {
      section[in]--;
      section[config[location[in] - 1]]++;
    }
    swap(config[location[in]], config[location[in] - 1]);
    location[in]--;
    location[config[location[in] + 1]]++;
  }
  printf("%lld\n", ans);
  return 0;
}
