# No.249 N言っちゃダメゲーム (2) n, k = [int(i) for i in input().split()] wins = 0 for i in range(1000): if n[i] % (k[i] + 1) != 1: wins += 1 print(wins)