#include <bits/stdc++.h>
using namespace std;
const long long OO = 0x0101010101010101;
class debug_t {
 public:
  template <typename T>
  debug_t& operator<<(const T& o) {
    return *this;
  }
  void end() {
    *this << "\nExecution Time = " << clock() * 1.0 / CLOCKS_PER_SEC << '\n';
    exit(0);
  }
} dout;
int dr[] = {0, 0, -1, 1};
int dc[] = {-1, 1, 0, 0};
int n, k;
int a[2000006], b[2000006], pos[2000006];
bool vis[2000006];
int bit[2000006];
void update(int x, int v) {
  for (; x < 2000006; x += (x & -x)) bit[x] += v;
}
int query(int x) {
  int res = 0;
  for (; x > 0; x -= (x & -x)) res += bit[x];
  return res;
}
int main() {
  scanf("%d%d", &n, &k);
  for (int i = 1; i <= n; i++) {
    scanf("%d", a + i);
    pos[a[i]] = i;
    update(pos[a[i]], 1);
  }
  for (int i = 1; i <= k; i++) {
    scanf("%d", b + i);
    vis[b[i]] = true;
  }
  set<int> se;
  se.insert(0), se.insert(n + 1);
  long long res = 0;
  for (int i = 1; i <= n; i++) {
    if (vis[i]) {
      se.insert(pos[i]);
      update(pos[i], -1);
    } else {
      auto it1 = se.lower_bound(pos[i]);
      auto it2 = it1--;
      res += query(*it2) - query(*it1);
      update(pos[i], -1);
    }
  }
  printf("%lld", res);
  dout.end();
}
