#include <bits/stdc++.h>
using namespace std;
int a[1010000];
int u[1010000];
inline bool cmp(int x, int y) { return a[x] > a[y]; }
bool XD[1010000];
int p[1010000];
int mi[5310000];
int cnt[5310000];
const int INF = 1000000000;
inline void up(int np) {
  mi[np] = min(mi[np * 2], mi[np * 2 + 1]);
  cnt[np] = cnt[np * 2] + cnt[np * 2 + 1];
}
inline void ins(int np, int l, int r, int x, int c) {
  if (l == r) {
    mi[np] = c;
    cnt[np] = (c == INF);
    return;
  }
  int m = (l + r) / 2;
  if (x <= m)
    ins(np * 2, l, m, x, c);
  else
    ins(np * 2 + 1, m + 1, r, x, c);
  up(np);
}
inline int cc(int np, int l, int r, int x, int y) {
  if (l == x && r == y) return cnt[np];
  int m = (l + r) / 2;
  if (x <= m && y > m)
    return cc(np * 2, l, m, x, m) + cc(np * 2 + 1, m + 1, r, m + 1, y);
  else if (x > m)
    return cc(np * 2 + 1, m + 1, r, x, y);
  else
    return cc(np * 2, l, m, x, y);
}
inline int flul(int np, int l, int r, int x, int c) {
  if (r == x) {
    if (mi[np] >= c) return l;
  }
  if (l == r) {
    return r + 1;
  }
  int m = (l + r) / 2;
  if (x <= m)
    return flul(np * 2, l, m, x, c);
  else {
    int ll = flul(np * 2 + 1, m + 1, r, x, c);
    if (ll > m + 1) return ll;
    return flul(np * 2, l, m, m, c);
  }
}
inline int frul(int np, int l, int r, int x, int c) {
  if (l == x) {
    if (mi[np] >= c) return r;
  }
  if (l == r) {
    return l - 1;
  }
  int m = (l + r) / 2;
  if (x > m)
    return frul(np * 2 + 1, m + 1, r, x, c);
  else {
    int rr = frul(np * 2, l, m, x, c);
    if (rr < m) return rr;
    return frul(np * 2 + 1, m + 1, r, m + 1, c);
  }
}
int main() {
  int n, k;
  scanf("%d%d", &n, &k);
  for (int i = 0; i < (n); i++) {
    scanf("%d", &a[i]);
    a[i]--;
  }
  for (int i = 0; i < (k); i++) {
    int x;
    scanf("%d", &x);
    x--;
    XD[x] = 1;
  }
  for (int i = 0; i < (n); i++) {
    p[a[i]] = i;
    if (XD[a[i]]) u[i] = 1;
  }
  for (int i = 0; i < (n); i++) ins(1, 0, n - 1, i, a[i]);
  long long ans = 0;
  for (int ii = 0; ii < (n); ii++) {
    int i = p[ii];
    if (u[i]) continue;
    int l = flul(1, 0, n - 1, i, a[i]);
    int r = frul(1, 0, n - 1, i, a[i]);
    ans += r - l + 1 - cc(1, 0, n - 1, l, r);
    ins(1, 0, n - 1, i, INF);
  }
  printf("%I64d\n", ans);
}
