# https://yukicoder.me/problems/no/3711 def main(): N, M = map(int, input().split()) U = list(map(int, input().split())) T = list(map(int, input().split())) sum_t = sum(T) # 天ぷらの選択についてのdp dp = [False] * (sum_t + 1) dp[0] = True for t in T: for m in reversed(range(sum_t + 1)): if m + t <= sum_t: dp[m + t] |= dp[m] answer_set = set() for u in U: for m in range(sum_t + 1): if dp[m]: ans = u + m answer_set.add(ans) print(len(answer_set)) if __name__ == "__main__": main()