#include <bits/stdc++.h>
using namespace std;
const double eps(1e-8);
int n, k;
int pos[1000010];
bool keep[1000010];
int C[1000010];
set<int> S, T;
int lowbit(int x) { return -x & x; }
void add(int x, int value) {
  while (x <= n) C[x] += value, x += lowbit(x);
  return;
}
int ask(int L, int R) {
  int ret = 0;
  while (R) ret += C[R], R -= lowbit(R);
  while (L) ret -= C[L], L -= lowbit(L);
  return ret;
}
int main() {
  scanf("%d %d", &n, &k);
  int tmp;
  for (int i = 1; i <= n; i++) scanf("%d", &tmp), pos[tmp] = i;
  for (int i = 1; i <= k; i++) scanf("%d", &tmp), keep[tmp] = 1;
  S.insert(0);
  S.insert(n + 1);
  T.insert(0);
  T.insert(-n - 1);
  long long ans = 0;
  for (int i = 1; i <= n; i++)
    if (keep[i])
      S.insert(pos[i]), T.insert(-pos[i]);
    else {
      int R = *S.upper_bound(pos[i]);
      int L = -*T.upper_bound(-pos[i]);
      ans += (R - L - 1);
      ans -= ask(L, R - 1);
      add(pos[i], 1);
    }
  printf("%I64d\n", ans);
  return 0;
}
