#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1000009;
int pos[MAXN];
bitset<MAXN> alive;
int BITA[MAXN], BITD[MAXN];
void Update(int idx, int* BIT) {
  while (idx < MAXN) {
    BIT[idx]++;
    idx += (idx & (-idx));
  }
}
long long Query(int idx, int* BIT) {
  long long res = 0;
  while (idx) {
    res += BIT[idx];
    idx -= (idx & (-idx));
  }
  return res;
}
long long Range(int I, int J, int* BIT) {
  return (Query(J, BIT) - Query(I - 1, BIT));
}
int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  int N, K;
  cin >> N >> K;
  for (int i = 1; i <= N; ++i) {
    int ax;
    cin >> ax;
    pos[ax] = i;
  }
  for (int i = 0; i < K; ++i) {
    int tmp;
    cin >> tmp;
    alive[tmp] = 1;
  }
  long long ans = 0;
  set<int> posal;
  for (int i = 1; i <= N; ++i) {
    if (alive[i]) {
      posal.insert(pos[i]);
    } else {
      int rans, lans;
      set<int>::iterator it = posal.upper_bound(pos[i]);
      if (it != posal.end())
        rans = (*it) - 1;
      else
        rans = N;
      if (it != posal.begin()) {
        it--;
        lans = (*it) + 1;
      } else
        lans = 1;
      long long posans = (rans - lans + 1);
      posans -= Range(lans, rans, BITD);
      ans += posans;
      Update(pos[i], BITD);
    }
  }
  cout << ans << '\n';
  return 0;
}
