#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9 + 10;
const long long LINF = 1000ll * 1000 * 1000 * 1000 * 1000 * 1000 + 100;
const int MN = 1e6 + 10;
int fen[MN];
set<int> pos;
long long ans;
int n, k;
int place[MN], p[MN];
bool is[MN];
void upd(int ind) {
  for (; ind <= n; ind += ind & -ind) fen[ind]++;
}
int get(int ind) {
  int ret = 0;
  for (; ind; ind -= ind & -ind) ret += fen[ind];
  return ret;
}
void input() {
  scanf("%d%d", &n, &k);
  for (int i = 1; i <= n; ++i) {
    scanf("%d", &p[i]);
    place[p[i]] = i;
  }
  int t;
  for (int i = 0; i < k; ++i) {
    scanf("%d", &t);
    is[t] = true;
  }
  pos.insert(0), pos.insert(n + 1);
}
void solve() {
  int L, R;
  set<int>::iterator it;
  for (int i = 1; i <= n; ++i) {
    it = pos.lower_bound(place[i]);
    R = *it;
    it--;
    L = *it;
    if (is[i]) {
      pos.insert(place[i]);
    } else {
      ans += R - L - 1 - (get(R - 1) - get(L));
      upd(place[i]);
    }
  }
  printf("%I64d\n", ans);
}
int main() {
  input();
  solve();
  return 0;
}
