#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 5;
set<int> s;
int bit[N], pos[N], a[N], b[N], n;
bool p[N];
void update(int idx) {
  idx++;
  while (idx < N) {
    bit[idx]++;
    idx += idx & (-idx);
  }
}
int sum(int idx) {
  idx++;
  int s = 0;
  while (idx > 0) {
    s += bit[idx];
    idx -= idx & (-idx);
  }
  return s;
}
int sum(int l, int r) {
  if (r < l) return 0;
  return sum(r) - sum(l - 1);
}
signed main() {
  if (0) freopen("inp.txt", "r", stdin);
  ios ::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int n, k;
  cin >> n >> k;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    pos[a[i]] = i;
  }
  for (int i = 1; i <= k; i++) {
    cin >> b[i];
    p[b[i]] = 1;
  }
  s.insert(0), s.insert(n + 1);
  long long int ans = 0;
  for (int i = 1; i <= n; i++) {
    if (p[i]) {
      s.insert(pos[i]);
      continue;
    }
    int pp = pos[i];
    auto it = s.upper_bound(pp);
    int r = *it;
    it--;
    int l = *it;
    ans += r - l - 1 - sum(l + 1, r - 1);
    update(pp);
  }
  cout << ans;
  return 0;
}
