#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1000 * 1000 + 5;
vector<pair<int, int> > V;
bool marked[MAXN];
set<int> S;
int sum[MAXN];
void add(int x, int val) {
  for (x; x < MAXN; x += (x & (-x))) sum[x] += val;
}
int get(int x) {
  int t = 0;
  for (x; x > 0; x -= (x & -x)) t += sum[x];
  return t;
}
int main() {
  int n, k;
  cin >> n >> k;
  for (int i = 1; i <= n; i++) {
    int a;
    cin >> a;
    V.push_back(pair<int, int>(a, i));
  }
  for (int i = 1; i <= k; i++) {
    int a;
    cin >> a;
    marked[a] = true;
  }
  sort(V.begin(), V.end());
  long long ans = 0;
  for (int i = 0; i < (int)V.size(); i++) {
    if (marked[V[i].first]) {
      S.insert(V[i].second);
      continue;
    }
    int left, right;
    set<int>::iterator x = S.lower_bound(V[i].second);
    if (x == S.end())
      right = n + 1;
    else
      right = *x;
    right--;
    if (x == S.begin())
      left = 1;
    else {
      x--;
      left = *x;
      left++;
    }
    ans += (long long)right - left + 1 - (get(right) - get(left - 1));
    add(V[i].second, 1);
  }
  cout << ans << endl;
  return 0;
}
