# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0593

"""
import sys
from sys import stdin
from collections import namedtuple, Counter
input = stdin.readline


class RMQ(object):
    INT_MAX = 2**31 - 1

    def __init__(self, nn, init_val=0):
        self.n = 1
        while self.n < nn:
            self.n *= 2
        self.dat = [init_val] * ((2 * self.n)-1)

    def update(self, k, a):
        # A[k]???a?????´??°?????????????????°???????????¨?????´??°
        k += (self.n - 1)
        self.dat[k] = a

        while k > 0:
            k = (k - 1) // 2        #  ??????index??????
            self.dat[k] = min(self.dat[k * 2 + 1], self.dat[k * 2 + 2]) #  ???????????¨??????????????????????°?????????????????????´??°

    def query(self, a, b, k, l, r):
        # [a, b)???????°????????±??????? (0????????§b???????????????)
        # ??????????????¨?????????query(a, b, 0, 0, n)?????¢??§??????????????????k, l, r???????????????????????´??°?????????
        if r <= a or b <= l:        #  ?????????????????§??¨??????????????????
            return RMQ.INT_MAX
        if a <=l and r <= b:
            return self.dat[k]           #  ???????????°???????????????????????§????????°????????¨??????????????????????°?????????????????????????
        else:
            vl = self.query(a, b, k*2+1, l, (l+r)//2) #  ????????°????????????????°????
            vr = self.query(a, b, k*2+2, (l+r)//2, r) #  ????????°????????????????°????
            return min(vl, vr)

    def find(self, s, t):
        return self.query(s, t+1, 0, 0, self.n)


event = namedtuple('event', ['num', 'cost'])
def main(args):
    N, M = map(int, input().split())
    rq = RMQ(1001, 999999)
    events = [event(i+1, int(input())) for i in range(N)] #  ??¶????????????1??????????????§???i+1???????????????
    events.reverse()            #  ??¢?????????????????????????????¶???????????¨?????????????????????
    #  ?????????(e.cost)??§????????§????????¶????????????(e.num)??§RMQ?????´??°????????????
    # events???????´????????????????????????¢??????????????\??£??????????????§???????????????????????¶???????????£?????´????????¢??????????????¶???????????§??????????????????
    for e in events:
        rq.update(e.cost, e.num)

    # ????\¨
    votes = []
    for _ in range(M):
        v = int(input())
       result = rq.find(0, v)  #  ?????????v?????§???????????????????????§??????????????¢????????¶????????????
       votes.append(result)
    ans = Counter(votes).most_common(1)[0][0]
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])

### FIXED CODE ###

# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0593

"""
import sys
from sys import stdin
from collections import namedtuple, Counter
input = stdin.readline


class RMQ(object):
    INT_MAX = 2**31 - 1

    def __init__(self, nn, init_val=0):
        self.n = 1
        while self.n < nn:
            self.n *= 2
        self.dat = [init_val] * ((2 * self.n)-1)

    def update(self, k, a):
        # A[k]???a?????´??°?????????????????°???????????¨?????´??°
        k += (self.n - 1)
        self.dat[k] = a

        while k > 0:
            k = (k - 1) // 2        #  ??????index??????
            self.dat[k] = min(self.dat[k * 2 + 1], self.dat[k * 2 + 2]) #  ???????????¨??????????????????????°?????????????????????´??°

    def query(self, a, b, k, l, r):
        # [a, b)???????°????????±??????? (0????????§b???????????????)
        # ??????????????¨?????????query(a, b, 0, 0, n)?????¢??§??????????????????k, l, r???????????????????????´??°?????????
        if r <= a or b <= l:        #  ?????????????????§??¨??????????????????
            return RMQ.INT_MAX
        if a <=l and r <= b:
            return self.dat[k]           #  ???????????°???????????????????????§????????°????????¨??????????????????????°?????????????????????????
        else:
            vl = self.query(a, b, k*2+1, l, (l+r)//2) #  ????????°????????????????°????
            vr = self.query(a, b, k*2+2, (l+r)//2, r) #  ????????°????????????????°????
            return min(vl, vr)

    def find(self, s, t):
        return self.query(s, t+1, 0, 0, self.n)


event = namedtuple('event', ['num', 'cost'])
def main(args):
    N, M = map(int, input().split())
    rq = RMQ(1001, 999999)
    events = [event(i+1, int(input())) for i in range(N)] #  ??¶????????????1??????????????§???i+1???????????????
    events.reverse()            #  ??¢?????????????????????????????¶???????????¨?????????????????????
    #  ?????????(e.cost)??§????????§????????¶????????????(e.num)??§RMQ?????´??°????????????
    # events???????´????????????????????????¢??????????????\??£??????????????§???????????????????????¶???????????£?????´????????¢??????????????¶???????????§??????????????????
    for e in events:
        rq.update(e.cost, e.num)

    # ????\¨
    votes = []
    for _ in range(M):
        v = int(input())
        result = rq.find(0, v)  #  ?????????v?????§???????????????????????§??????????????¢????????¶????????????
        votes.append(result)
    ans = Counter(votes).most_common(1)[0][0]
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])