#include <bits/stdc++.h>
using namespace std;
set<long> rem;
long n, k, ar[1200000], ps[1200000], need[1200000];
long q, t;
set<long>::iterator it;
long l, r;
long tt[3200000];
long long ans;
long sum(long v, long tl, long tr, long l, long r) {
  if (l > r) return 0;
  if (l == tl && r == tr) {
    return tt[v];
  }
  long sdfjahlfasfh = tl + tr;
  sdfjahlfasfh /= 2;
  return sum(v * 2, tl, sdfjahlfasfh, l, min(r, sdfjahlfasfh)) +
         sum(v * 2 + 1, sdfjahlfasfh + 1, tr, max(l, sdfjahlfasfh + 1), r);
}
void update(long v, long tl, long tr, long pos, long val) {
  if (tl == tr) {
    tt[v] = val;
    return;
  }
  long sdfjahlfasfh = tl + tr;
  sdfjahlfasfh /= 2;
  if (pos <= sdfjahlfasfh)
    update(v * 2, tl, sdfjahlfasfh, pos, val);
  else
    update(v * 2 + 1, sdfjahlfasfh + 1, tr, pos, val);
  tt[v] = tt[v * 2] + tt[v * 2 + 1];
}
int main() {
  ios_base::sync_with_stdio(0);
  cin >> n >> k;
  for (int i = 1; i <= n; i++) {
    cin >> ar[i];
    ps[ar[i]] = i;
  }
  rem.insert(0);
  rem.insert(n + 1);
  for (int i = 1; i <= k; i++) {
    cin >> q;
    need[q] = 1;
  }
  for (int i = 1; i <= n; i++) {
    t = ps[i];
    it = rem.lower_bound(t);
    --it;
    l = (*it);
    it = rem.lower_bound(t);
    r = (*it);
    ++l;
    --r;
    if (need[i] == 0) {
      ans += r - l + 1 - sum(1, 1, n, l, r);
      update(1, 1, n, t, 1);
    } else
      rem.insert(t);
  }
  cout << ans << endl;
  cin.get();
  cin.get();
  return 0;
}
