#include <bits/stdc++.h>
using namespace std;
long long a[1000000];
long long t[4000000];
long long get_pos[1000000];
long long mas[1000000];
long long dd[1000000];
void built(long long v, long long tl, long long tr) {
  if (tl == tr) {
    t[v] = dd[tl];
    return;
  }
  long long tm = (tl + tr) / 2;
  built(v * 2, tl, tm);
  built(v * 2 + 1, tm + 1, tr);
  t[v] = t[v * 2] + t[v * 2 + 1];
}
long long get_sum(long long v, long long tl, long long tr, long long l,
                  long long r) {
  if (l > tr || tl > r) {
    return 0;
  }
  if (tl >= l && tr <= r) {
    return t[v];
  }
  long long tm = (tl + tr) / 2;
  return get_sum(v * 2, tl, tm, l, r) + get_sum(v * 2 + 1, tm + 1, tr, l, r);
}
void obnova(long long v, long long tl, long long tr, long long pos,
            long long x) {
  if (tl == tr) {
    t[v] = x;
    return;
  }
  long long tm = (tl + tr) / 2;
  if (pos <= tm) {
    obnova(v * 2, tl, tm, pos, x);
  } else {
    obnova(v * 2 + 1, tm + 1, tr, pos, x);
  }
  t[v] = t[v * 2] + t[v * 2 + 1];
}
long long ans;
signed main() {
  long long n, k;
  cin >> n >> k;
  for (long long i = 1; i <= n; ++i) {
    scanf("%d", &a[i]);
    get_pos[a[i]] = i;
    dd[i] = 1;
  }
  built(1, 1, n);
  for (long long i = 1; i <= k; ++i) {
    long long kk;
    scanf("%d", &kk);
    mas[kk] = 1;
  }
  set<long long> ss;
  ss.insert(0);
  ss.insert(n + 1);
  for (long long i = 1; i <= n; ++i) {
    if (mas[i]) {
      ss.insert(get_pos[i]);
    } else {
      auto r = ss.upper_bound(get_pos[i]);
      long long rr = *r;
      auto l = --r;
      long long ll = *l;
      ans += get_sum(1, 1, n, ll + 1, rr - 1);
      obnova(1, 1, n, get_pos[i], 0);
    }
  }
  cout << ans << endl;
}
