#include <bits/stdc++.h>
using namespace std;
int n, k, a, r, l;
int pos[1000050];
int num[1000050];
int b[1000050];
int lowbit(int o) { return o & -o; }
int query(int o) {
  int res = 0;
  while (o > 0) res += b[o], o -= lowbit(o);
  return res;
}
void insert(int o) {
  while (o <= n) b[o]++, o += lowbit(o);
}
int main() {
  memset(pos, 0, sizeof(pos));
  memset(num, false, sizeof(num));
  memset(b, 0, sizeof(b));
  scanf("%d%d", &n, &k);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a);
    pos[a] = i;
  }
  for (int i = 0; i < k; i++) {
    scanf("%d", &a);
    num[a] = 1;
  }
  long long ans = 0;
  set<int> position;
  set<int>::iterator it;
  for (int i = 1; i <= n; i++) {
    if (num[i] == 1) {
      position.insert(pos[i]);
    } else {
      int r, l;
      it = position.upper_bound(pos[i]);
      if (it == position.begin()) {
        if (position.size() == 0) {
          r = n;
          l = 1;
        } else {
          l = 1;
          r = *(it)-1;
        }
      } else if (it == position.end()) {
        l = (*(--it)) + 1;
        r = n;
      } else {
        r = *it - 1;
        l = (*(--it)) + 1;
      }
      ans += r - l + 1;
      ans -= query(r) - query(l - 1);
      insert(pos[i]);
    }
  }
  printf("%lld\n", ans);
  return 0;
}
