#include <bits/stdc++.h>
using namespace std;
const int nMax = 1e6 + 10;
int a[nMax], pos[nMax], num[nMax], use[nMax], del[nMax];
int n;
void take_plus(int x) {
  while (x < nMax) {
    a[x]++;
    x += (x & (-x));
  }
}
int take_sum(int x) {
  int ret = 0;
  while (x >= 1) {
    ret += a[x];
    x -= (x & (-x));
  }
  return ret;
}
int main() {
  int k;
  scanf("%d%d", &n, &k);
  memset(pos, 0, sizeof(pos));
  memset(use, 0, sizeof(use));
  for (int i = 1; i <= n; i++) {
    scanf("%d", &num[i]);
    pos[num[i]] = i;
  }
  for (int i = 1; i <= k; i++) {
    scanf("%d", &del[i]);
    use[del[i]] = 1;
  }
  set<int> scc;
  scc.insert(0);
  scc.insert(n + 1);
  long long ans = 0;
  for (int i = 1; i < nMax; i++) {
    if (!pos[i]) continue;
    if (use[i])
      scc.insert(pos[i]);
    else {
      int r = *scc.lower_bound(pos[i]), l = *--scc.lower_bound(pos[i]);
      ans += r - l - 1 - (take_sum(r) - take_sum(l - 1));
      take_plus(pos[i]);
    }
  }
  cout << ans << endl;
}
