N, M = map(int, input().split()) U = list(map(int, input().split())) T = list(map(int, input().split())) dp = [False]*(10**5+1) dp[0] = True for t in T: for i in reversed(range(10**5+1)): if i+t <= 10**5: dp[i+t] |= dp[i] ans = 0 dp2 = [False]*(10**5*2+1) for u in U: for i in range(10**5+1): if dp[i]: dp2[u+i] = True print(sum(dp2))