#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e6 + 100;
const int INF = 0x3f3f3f3f;
const int MOD = 1e9 + 7;
int n, k;
set<int> s;
int bit[MAXN];
int pos[MAXN];
int need[MAXN];
inline void update(int i) {
  for (; i < MAXN; i += i & -i) {
    bit[i]++;
  }
}
inline int query(int i) {
  int sum = 0;
  for (; i; i -= i & -i) {
    sum += bit[i];
  }
  return sum;
}
int main() {
  scanf("%d %d", &n, &k);
  for (int i = 1; i <= n; i++) {
    int t;
    scanf("%d", &t);
    pos[t] = i;
  }
  for (int i = 1; i <= k; i++) {
    int t;
    scanf("%d", &t);
    need[t] = 1;
  }
  s.insert(0);
  s.insert(n + 1);
  set<int>::iterator it;
  long long ans = 0;
  for (int i = 1; i <= n; i++) {
    if (need[i]) {
      s.insert(pos[i]);
    } else {
      it = s.upper_bound(pos[i]);
      int r = *it;
      it--;
      int l = *it;
      int t = query(r - 1) - query(l);
      ans += (r - l - 1 - t);
      update(pos[i]);
    }
  }
  cout << ans << endl;
}
