#include <bits/stdc++.h>
using namespace std;
int dx4[] = {-1, 0, 1, 0};
int dy4[] = {0, 1, 0, -1};
int dx8[] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dy8[] = {0, 1, 1, 1, 0, -1, -1, -1};
bool AreEqual(double a, double b) { return (fabs(a - b) < 1e-10); }
template <class T>
bool GetNr(T &_value) {
  T _sign = 1;
  char ch;
  _value = 0;
  while (!isdigit(ch = getchar())) {
    if (ch == -1) return false;
    ch == '-' ? _sign = -1 : _sign = 1;
  }
  do {
    _value = _value * 10 + (ch - '0');
  } while (isdigit(ch = getchar()));
  _value *= _sign;
  return true;
}
int N, K;
long long ans;
vector<int> aib, where;
vector<bool> keep;
set<int> sset;
void InsertAib(int pos, int val) {
  for (; pos <= N; pos += pos & -pos) {
    aib[pos] += val;
  }
}
int QueryAib(int pos) {
  int ans = 0;
  for (; pos; pos -= pos & -pos) {
    ans += aib[pos];
  }
  return ans;
}
int main() {
  int i;
  GetNr(N);
  GetNr(K);
  aib.resize(2 + N);
  where.resize(1 + N);
  keep.resize(1 + N);
  for (i = 1; i <= N; ++i) {
    int x;
    GetNr(x);
    where[x] = i;
    InsertAib(i, 1);
  }
  for (i = 1; i <= K; ++i) {
    int x;
    GetNr(x);
    keep[x] = 1;
  }
  sset.insert(0);
  sset.insert(N + 1);
  for (i = 1; i <= N; ++i) {
    if (keep[i]) {
      sset.insert(where[i]);
      continue;
    }
    auto it = sset.upper_bound(where[i]);
    int en = *it - 1;
    int st = *(--it);
    ans += QueryAib(en) - QueryAib(st);
    InsertAib(where[i], -1);
  }
  cout << ans << '\n';
  return 0;
}
