#include <bits/stdc++.h>
using namespace std;
long long powmod(long long base, long long exponent, long long mod) {
  long long ans = 1;
  while (exponent) {
    if (exponent & 1) ans = (ans * base) % mod;
    base = (base * base) % mod;
    exponent /= 2;
  }
  return ans;
}
long long gcd(long long a, long long b) {
  if (b == 0)
    return a;
  else
    return gcd(b, a % b);
}
const int upperlimit = 1e6 + 1;
const int mod = 1e9 + 7;
struct data {
  int ind, val, s;
};
data merge(data a, data b) {
  data ans;
  if (a.val < b.val)
    ans.ind = a.ind;
  else
    ans.ind = b.ind;
  ans.s = a.s + b.s;
  ans.val = min(a.val, b.val);
  return ans;
}
int arr[upperlimit];
int indices[upperlimit];
data segtree[4 * upperlimit];
int answer[upperlimit];
bool visited[upperlimit];
void build(int node, int i, int j) {
  if (i == j) {
    segtree[node].val = arr[i];
    segtree[node].ind = i;
    segtree[node].s = 1;
    return;
  }
  int mid = (i + j) >> 1;
  build(2 * node, i, mid);
  build(2 * node + 1, mid + 1, j);
  segtree[node] = merge(segtree[2 * node], segtree[2 * node + 1]);
}
void update(int node, int i, int j, int ind, int val1, int val2) {
  if (i == j) {
    segtree[node].val = val1;
    segtree[node].s = val2;
    return;
  }
  int mid = (i + j) >> 1;
  if (ind <= mid)
    update(2 * node, i, mid, ind, val1, val2);
  else
    update(2 * node + 1, mid + 1, j, ind, val1, val2);
  segtree[node] = merge(segtree[2 * node], segtree[2 * node + 1]);
}
data query(int node, int i, int j, int l, int r) {
  if ((i > r) || (l > j) || (i > j) || (l > r)) {
    data id;
    id.val = 2e9;
    id.ind = 0;
    id.s = 0;
    return id;
  }
  if ((i >= l) && (j <= r)) return segtree[node];
  int mid = (i + j) >> 1;
  return merge(query(2 * node, i, mid, l, r),
               query(2 * node + 1, mid + 1, j, l, r));
}
int n;
void func(int i, int j) {
  if (i > j) return;
  data temp = query(1, 1, n, i, j);
  if (temp.s == 0) return;
  answer[temp.ind] = temp.s;
  if (!visited[arr[temp.ind]]) {
    update(1, 1, n, temp.ind, 2e9, 0);
    func(i, j);
  } else {
    func(i, temp.ind - 1);
    func(temp.ind + 1, j);
  }
}
int main() {
  long long ans = 0;
  int k, inp;
  scanf("%d", &n);
  scanf("%d", &k);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &arr[i]);
    indices[arr[i]] = i;
  }
  build(1, 1, n);
  for (int i = 1; i <= k; i++) {
    scanf("%d", &inp);
    visited[inp] = true;
  }
  func(1, n);
  for (int i = 1; i <= n; i++) {
    if (visited[i]) continue;
    ans += answer[indices[i]];
  }
  printf("%lld", ans);
  return 0;
}
