#include <bits/stdc++.h>
using namespace std;
bool debug = 1;
int n, m, k;
int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};
long long ln, lk, lm;
int p[1000005], pos[1000005], b[1000005], l[1000005], r[1000005];
bool vb[1000005];
int M, T[1 << 21];
void update(int l, int v) {
  l += M;
  while (l >= 1) {
    T[l] += v;
    l >>= 1;
  }
}
int qy(int l, int r) {
  assert(l <= r);
  int ans = 0;
  for (l = l + M - 1, r = r + M + 1; l ^ r ^ 1; l >>= 1, r >>= 1) {
    if (~l & 1) ans += T[l ^ 1];
    if (r & 1) ans += T[r ^ 1];
  }
  return ans;
}
int main() {
  scanf("%d%d", &n, &k);
  for (int(i) = 1; (i) <= (int)(n); (i)++) {
    scanf("%d", p + i);
    pos[p[i]] = i;
  }
  for (int(i) = 1; (i) <= (int)(k); (i)++) {
    scanf("%d", b + i);
    vb[b[i]] = 1;
  }
  sort(b + 1, b + 1 + k);
  set<int> ss;
  ss.insert(0);
  ss.insert(n + 1);
  for (M = 1; n + 2 > M; M <<= 1)
    ;
  long long ans = 0;
  for (int i = 1, j = 1; i <= n; i++)
    if (!vb[i]) {
      while (j <= k && b[j] < i) ss.insert(pos[b[j++]]);
      auto it = ss.lower_bound(pos[i]);
      r[i] = *it;
      it--;
      l[i] = *it;
      int len = r[i] - l[i] - 1;
      int del = qy(l[i] + 1, r[i] - 1);
      ans += len - del;
      update(pos[i], 1);
    }
  printf("%lld\n", ans);
  return 0;
}
