N, M = map(int, input().split()) U = set(map(int, input().split())) T = list(map(int, input().split())) tmax = sum(T) dp = [False] * (tmax +1) dp[0] = True for t in T: for cur in range(tmax, t-1, -1): dp[cur] = dp[cur] | dp[cur-t] G = set() for i in range(tmax+1): if dp[i]: G.add(i) ans = set() for u in U: for g in G: ans.add(u+g) print(len(ans))