#include <bits/stdc++.h>
#pragma warning(disable : 4996)
using namespace std;
int n, m;
int a[1111111], b[1111111], pos[1111111], vis[1111111], sum[1111111];
set<int> mp;
int que(int x) {
  int re = 0;
  while (x) {
    re += sum[x];
    x -= ((x) & (-(x)));
  }
  return re;
}
void add(int x) {
  while (x < 1111111) {
    sum[x]++;
    x += ((x) & (-(x)));
  }
}
int main() {
  int t, x, y, z, ca = 1;
  scanf("%d%d", &(n), &(m));
  for (int i = (int)(1); i <= (int)(n); ++i)
    scanf("%d", &(a[i])), pos[a[i]] = i;
  for (int i = (int)(1); i <= (int)(m); ++i)
    scanf("%d", &(b[i])), vis[b[i]] = 1;
  mp.insert(0), mp.insert(n + 1);
  int st = 0, en = 0;
  long long ans = 0;
  for (int i = (int)(1); i <= (int)(n); ++i) {
    if (vis[i] == 0) {
      auto itr = mp.lower_bound(pos[i]);
      itr--;
      st = *itr;
      itr = mp.upper_bound(pos[i]);
      en = *itr;
      ans += en - st - 1 - (que(en - 1) - que(st));
      add(pos[i]);
    } else
      mp.insert(pos[i]);
  }
  printf("%I64d\n", (ans));
  return 0;
}
