#include <bits/stdc++.h>
using namespace std;
int pos[1000010], bit[1000010], n;
inline int lowbit(int x) { return x & -x; }
inline void modify(int pos, int add) {
  for (int i = pos; i <= n; i += lowbit(i)) bit[i] += add;
}
inline int query(int pos) {
  int res = 0;
  for (int i = pos; i > 0; i -= lowbit(i)) res += bit[i];
  return res;
}
inline int getSum(int l, int r) {
  if (l > r) return 0;
  return query(r) - query(l - 1);
}
bool not_del[1000010];
set<int> dic;
int main() {
  int k, a, b;
  scanf("%d%d", &n, &k);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a);
    pos[a] = i;
    modify(i, 1);
  }
  for (int i = 1; i <= k; i++) {
    scanf("%d", &b);
    not_del[b] = true;
  }
  dic.insert(0);
  dic.insert(n + 1);
  long long ans = 0;
  for (int i = 1; i <= n; i++) {
    if (not_del[i]) {
      dic.insert(pos[i]);
    } else {
      auto it = dic.lower_bound(pos[i]);
      ans += getSum(pos[i] + 1, *it - 1);
      it--;
      ans += getSum(*it + 1, pos[i] - 1);
      ans++;
      modify(pos[i], -1);
    }
  }
  printf("%lld\n", ans);
  return 0;
}
