#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie();
  long long int b, i, n, m, k, sc = -1, ans = 0;
  map<long long int, long long int> mp1, mp2;
  cin >> n >> m >> k;
  long long int a[n + 5];
  for (i = 1; i <= n; i++) {
    cin >> a[i];
    mp1[a[i]] = i;
    if (i % k == 1 or k == 1) ++sc;
    mp2[a[i]] = sc;
  }
  for (i = 1; i <= m; i++) {
    cin >> b;
    ans += mp2[b] + 1;
    if (b == a[1]) continue;
    if (mp1[b] % k == 1 or k == 1) --mp2[b], ++mp2[a[mp1[b] - 1]];
    long long int tmp = a[mp1[b]];
    a[mp1[b]] = a[mp1[b] - 1], a[mp1[b] - 1] = tmp;
    ++mp1[a[mp1[b]]], --mp1[a[mp1[b] - 1]];
  }
  cout << ans;
}
