George is a cat, so he loves playing very much.

Vitaly put n cards in a row in front of George. Each card has one integer written on it. All cards had distinct numbers written on them. Let's number the cards from the left to the right with integers from 1 to n. Then the i-th card from the left contains number pi (1 ≤ pi ≤ n). 

Vitaly wants the row to have exactly k cards left. He also wants the i-th card from left to have number bi written on it. Vitaly gave a task to George, to get the required sequence of cards using the remove operation n - k times.

In one remove operation George can choose w (1 ≤ w; w is not greater than the current number of cards in the row) contiguous cards (contiguous subsegment of cards). Let's denote the numbers written on these card as x1, x2, ..., xw (from the left to the right). After that, George can remove the card xi, such that xi ≤ xj for each j (1 ≤ j ≤ w). After the described operation George gets w pieces of sausage.

George wondered: what maximum number of pieces of sausage will he get in total if he reaches his goal and acts optimally well? Help George, find an answer to his question!

Input

The first line contains integers n and k (1 ≤ k ≤ n ≤ 106) — the initial and the final number of cards.

The second line contains n distinct space-separated integers p1, p2, ..., pn (1 ≤ pi ≤ n) — the initial row of cards. 

The third line contains k space-separated integers b1, b2, ..., bk — the row of cards that you need to get. It is guaranteed that it's possible to obtain the given row by using the remove operation for n - k times.

Output

Print a single integer — the maximum number of pieces of sausage that George can get if he acts optimally well.

Examples

Input

3 2
2 1 3
1 3


Output

1


Input

10 5
1 2 3 4 5 6 7 8 9 10
2 4 6 8 10


Output

30
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1000000 + 3;
int bit1[MAXN];
int bit2[MAXN];
int p[MAXN];
int at[MAXN];
bool is[MAXN];
inline int lb(int x) { return x & (-x); }
void update(int x, int add, int n, int bit[]) {
  while (x <= n) {
    bit[x] += add;
    x += lb(x);
  }
}
int query(int x, int n, int bit[]) {
  int res = 0;
  while (x > 0 && x <= n) {
    res += bit[x];
    x -= lb(x);
  }
  return res;
}
int bs_l(int x, int n) {
  int l = 0, r = x, mid;
  while (r - l > 1) {
    mid = (l + r) >> 1;
    if (query(x, n, bit1) - query(mid - 1, n, bit1) == 0)
      r = mid;
    else
      l = mid;
  }
  return r;
}
int bs_r(int x, int n) {
  int l = x, r = n + 1, mid;
  while (r - l > 1) {
    mid = (l + r) >> 1;
    if (query(mid, n, bit1) - query(x - 1, n, bit1) == 0)
      l = mid;
    else
      r = mid;
  }
  return l;
}
void solve(int n, int k) {
  memset(bit1, 0, sizeof bit1);
  memset(bit2, 0, sizeof bit2);
  long long ans = 0;
  for (int i = 1, l, r; i <= n; i++) {
    if (is[i]) {
      update(at[i], 1, n, bit1);
    } else {
      l = bs_l(at[i], n);
      r = bs_r(at[i], n);
      ans += (long long)(r - l + 1) - query(r, n, bit2) + query(l - 1, n, bit2);
      update(at[i], 1, n, bit2);
    }
  }
  cout << ans << endl;
}
int main() {
  memset(is, false, sizeof is);
  int n, k;
  scanf("%d %d", &n, &k);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &p[i]);
    at[p[i]] = i;
  }
  for (int i = 1, u; i <= k; i++) {
    scanf("%d", &u);
    is[u] = true;
  }
  solve(n, k);
  return 0;
}
