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
import java.io.*;
import java.util.*;

public class E {

    int n;
    int offset;
    int[] h, c;

    int right(int i) {
        i += offset;
        int v = h[i];
        while (i > 1 && ((i & 1) == 1 || v <= h[i + 1])) {
            i >>= 1;
        }
        if (i == 1) {
            return n - 1;
        }
        ++i;
        while (i < offset) {
            int l = i << 1;
            int r = l + 1;
            if (h[l] < v) {
                i = l;
            } else {
                i = r;
            }
        }
        return i - offset - 1;
    }

    int left(int i) {
        i += offset;
        int v = h[i];
        while (i > 1 && ((i & 1) == 0 || v <= h[i - 1])) {
            i >>= 1;
        }
        if (i == 1) {
            return 0;
        }
        --i;
        while (i < offset) {
            int l = i << 1;
            int r = l + 1;
            if (h[r] < v) {
                i = r;
            } else {
                i = l;
            }
        }
        return i - offset + 1;
    }

    int count(int l, int r) {
        if (l == r) {
            return c[l + offset];
        }
        l += offset;
        r += offset;
        int result = c[l] + c[r];
        while ((l >> 1) != (r >> 1)) {
            if ((l & 1) == 0) {
                result += c[l + 1];
            }
            if ((r & 1) == 1) {
                result += c[r - 1];
            }
            l >>= 1;
            r >>= 1;
        }
        return result;
    }

    void update(int i) {
        i += offset;
        h[i] = n;
        c[i] = 1;
        i >>= 1;
        while (i > 0) {
            int l = i << 1;
            int r = l + 1;
            h[i] = Math.min(h[l], h[r]);
            ++c[i];
            i >>= 1;
        }
    }

    void solve() throws IOException {
        in = new InputReader("__std");
        out = new OutputWriter("__std");

        n = in.readInt();
        int k = in.readInt();

        offset = 1;
        while (offset < n) offset <<= 1;
        h = new int[offset << 1];
        c = new int[offset << 1];

        int[] t = new int[n];
        for (int i = 0; i < n; ++i) {
            int p = in.readInt() - 1;
            t[p] = i;
            h[offset + i] = p;
        }

        for (int i = offset - 1; i > 1; --i) {
            int l = i << 1;
            int r = l + 1;
            h[i] = Math.min(h[l], h[r]);
        }

        boolean[] mask = new boolean[n];
        for (int i = 0; i < k; ++i) {
            int b = in.readInt() - 1;
            mask[b] = true;
        }

        long sum = 0;
        for (int i = 0; i < n; ++i) {
            if (!mask[i]) {
                int l = left(t[i]);
                int r = right(t[i]);
                sum += r - l - count(l, r) + 1;
                update(t[i]);
            }
        }

        out.println(sum);

        exit();
    }

    void exit() {
        //System.err.println((System.currentTimeMillis() - startTime) + " ms");
        out.close();
        System.exit(0);
    }

    InputReader in;
    OutputWriter out;

    //long startTime = System.currentTimeMillis();

    public static void main(String[] args) throws IOException {
        new E().solve();
    }

    class InputReader {

        private InputStream stream;

        private byte[] buffer = new byte[1024];
        private int pos, len;

        private int cur;

        private StringBuilder sb = new StringBuilder(32);

        InputReader(String name) throws IOException {
            if (name.equals("__std")) {
                stream = System.in;
            } else {
                stream = new FileInputStream(name);
            }
            cur = read();
        }

        private int read() throws IOException {
            if (len == -1) {
                throw new EOFException();
            }
            if (pos >= len) {
                pos = 0;
                len = stream.read(buffer);
                if (len == -1) return -1;
            }
            return buffer[pos++];
        }

        char readChar() throws IOException {
            if (cur == -1) {
                throw new EOFException();
            }
            char res = (char) cur;
            cur = read();
            return res;
        }

        int readInt() throws IOException {
            if (cur == -1) {
                throw new EOFException();
            }
            while (whitespace()) {
                cur = read();
            }
            if (cur == -1) {
                throw new EOFException();
            }
            int sign = 1;
            if (cur == '-') {
                sign = -1;
                cur = read();
            }
            int res = 0;
            while (!whitespace()) {
                if (cur < '0' || cur > '9') {
                    throw new NumberFormatException();
                }
                res *= 10;
                res += cur - '0';
                cur = read();
            }
            return res * sign;
        }

        long readLong() throws IOException {
            if (cur == -1) {
                throw new EOFException();
            }
            return Long.parseLong(readToken());
        }

        double readDouble() throws IOException {
            if (cur == -1) {
                throw new EOFException();
            }
            return Double.parseDouble(readToken());
        }

        String readLine() throws IOException {
            if (cur == -1) {
                throw new EOFException();
            }
            sb.setLength(0);
            while (cur != -1 && cur != '\r' && cur != '\n') {
                sb.append((char) cur);
                cur = read();
            }
            if (cur == '\r') {
                cur = read();
            }
            if (cur == '\n') {
                cur = read();
            }
            return sb.toString();
        }

        String readToken() throws IOException {
            if (cur == -1) {
                throw new EOFException();
            }
            while (whitespace()) {
                cur = read();
            }
            if (cur == -1) {
                throw new EOFException();
            }
            sb.setLength(0);
            while (!whitespace()) {
                sb.append((char) cur);
                cur = read();
            }
            return sb.toString();
        }

        boolean whitespace() {
            return cur == ' ' || cur == '\t' || cur == '\r' || cur == '\n' || cur == -1;
        }

        boolean eof() {
            return cur == -1;
        }
    }

    class OutputWriter {

        private PrintWriter writer;

        OutputWriter(String name) throws IOException {
            if (name.equals("__std")) {
                writer = new PrintWriter(System.out);
            } else {
                writer = new PrintWriter(name);
            }
        }

        void print(String format, Object ... args) {
            writer.print(new Formatter(Locale.US).format(format, args));
        }

        void println(String format, Object ... args) {
            writer.println(new Formatter(Locale.US).format(format, args));
        }

        void print(Object value) {
            writer.print(value);
        }

        void println(Object value) {
            writer.println(value);
        }

        void println() {
            writer.println();
        }

        void close() {
            writer.close();
        }
    }
}
