#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const double EPS = 1e-11;
const double PI = 3.141592653589793;
const int MAX_N = 100005;
const long long LLINF = 99999999999999999LL;
int N, M, K;
int v[MAX_N], scr[MAX_N], pos[MAX_N];
vector<int> screen[MAX_N];
long long ans;
int main() {
  cin >> N >> M >> K;
  int n = 0;
  for (int i = 1, ind = -1; i <= N; ++i) {
    if (i % K == 1 || K == 1) {
      ++n;
      ind = -1;
    }
    ++ind;
    int x;
    scanf("%d", &x);
    screen[n].push_back(x);
    scr[x] = n;
    pos[x] = ind;
  }
  for (int i = 1; i <= M; ++i) {
    int x;
    scanf("%d", &x);
    ans += scr[x];
    if (pos[x] > 0) {
      int y = screen[scr[x]][pos[x] - 1];
      swap(screen[scr[x]][pos[x]], screen[scr[x]][pos[x] - 1]);
      swap(pos[x], pos[y]);
    } else if (scr[x] != 1) {
      int k = scr[x] - 1;
      int p = screen[k].size() - 1;
      int y = screen[k][p];
      swap(screen[scr[x]][pos[x]], screen[k][p]);
      swap(pos[x], pos[y]);
      swap(scr[x], scr[y]);
    }
  }
  cout << ans;
  return 0;
}
