n, m = list(map(int, input().split())) A = list(map(int, input().split())) B = list(map(int, input().split())) N = 10**5 dp = [0] * (N+1) dp[0] = 1 for b in B: for t in range(N, b-1, -1): if dp[t-b]: dp[t] = 1 C = set() for a in A: for b in range(N+1): if dp[b]: C.add(a+b) print(len(C))