#include <bits/stdc++.h>
bool Stay[2100000];
int A[2100000], Cards[2100000], Low[2100000], High[2100000], Pos[2100000], N, K;
using namespace std;
void updateLow(int x) {
  int n = x;
  while (n <= N) {
    Low[n] = max(Low[n], x);
    n += (n & -n);
  }
}
int queryLow(int x) {
  int ret = 0;
  while (x > 0) {
    ret = max(ret, Low[x]);
    x -= (x & -x);
  }
  return ret;
}
void updateHigh(int x) {
  int n = x;
  while (n > 0) {
    High[n] = min(High[n], x);
    n -= (n & -n);
  }
}
int queryHigh(int x) {
  int ret = N + 1;
  while (x <= N) {
    ret = min(ret, High[x]);
    x += (x & -x);
  }
  return ret;
}
void updateCards(int x, int v) {
  while (x <= N) {
    Cards[x] += v;
    x += (x & -x);
  }
}
int queryCards(int x) {
  int ret = 0;
  while (x > 0) {
    ret += Cards[x];
    x -= (x & -x);
  }
  return ret;
}
int queryCards(int l, int r) { return queryCards(r) - queryCards(l - 1); }
int main() {
  cin >> N >> K;
  for (int i = 0; i < 2100000; i++) High[i] = N + 1;
  for (int i = 1; i <= N; i++) {
    cin >> A[i];
    Pos[A[i]] = i;
    updateCards(i, 1);
  }
  for (int i = 1; i <= K; i++) {
    int x;
    cin >> x;
    Stay[x] = true;
  }
  long long ans = 0;
  for (int i = 1; i <= N; i++)
    if (Stay[i]) {
      updateLow(Pos[i]);
      updateHigh(Pos[i]);
    } else {
      int l = queryLow(Pos[i]) + 1;
      int r = queryHigh(Pos[i]) - 1;
      ans += queryCards(l, r);
      updateCards(Pos[i], -1);
    }
  cout << ans;
}
