N, M = [int(s) for s in input().split()] U = [int(s) for s in input().split()] T = [int(s) for s in input().split()] dp = 1 for t in T: dp |= dp << t cand = set() for d in range(dp.bit_length()): if (dp >> d) & 1 == 1: cand.update([d + u for u in U]) print(len(cand))