#!/usr/bin/env python def read(): input() wList = map(int, raw_input().split()) input() bList = map(int, raw_input().split()) return wList, bList def work((wList, bList)): lengColorList = [] # (leng, isWhite) for leng in wList: lengColorList.append((leng, True)) for leng in bList: lengColorList.append((leng, False)) lengColorList.sort() # dp[lastColor][lastLeng]: best height dp = [[-1 for j in range(21)] for i in range(2)] dp[0][0] = 0 dp[1][0] = 0 for (leng, isWhite) in lengColorList: for lastLeng in range(leng): if dp[not isWhite][lastLeng] == -1: continue dp[isWhite][leng] = max(dp[isWhite][leng], dp[not isWhite][lastLeng] + 1) print max(max(dp[0]), max(dp[1])) if __name__ == "__main__": work(read())