n = int(input()) a = list(map(int,input().split())) b = list(map(int,input().split())) c = list(map(int,input().split())) ans = 0 for i in a: if i % 3 != 0: for j in b: if j % 3 != 0: for k in c: if k % 3 != 0: ans += 1 print(ans)