1)a = list(map(int, input().split()))
c = 0
for i in range(len(a)):
d = str(a[i])
d = d[:len(d):-1]
if a[i] % 6 = 0 and d == 4:
c += 1
print(c)
2)a = list(map(int, input().split()))
c = 0
for i in range(len(a)):
d = str(a[i])
d = d[:len(d):-1]
if a[i] % 3 = 0 and d == 4:
c += a[i]
print(c)