import collections
n, m = map(int, input().split())
h = []
for i in range(n):
    h[len(h):len(h)] = list(map(int, input().split()))[1:]
ans = 0
count = collections.Counter(h)
for v in count.values():
    if v == n:
        ans += 1
print(ans)

92980abd5aa4c88b060d1779c255a5237a1b35ff
<mask token>

<mask token>
for i in range(n):
    h[len(h):len(h)] = list(map(int, input().split()))[1:]
<mask token>
for v in count.values():
    if v == n:
        ans += 1
print(ans)

<mask token>
n, m = map(int, input().split())
h = []
for i in range(n):
    h[len(h):len(h)] = list(map(int, input().split()))[1:]
ans = 0
count = collections.Counter(h)
for v in count.values():
    if v == n:
        ans += 1
print(ans)

import collections
n, m = map(int, input().split())
h = []
for i in range(n):
    h[len(h):len(h)] = list(map(int, input().split()))[1:]
ans = 0
count = collections.Counter(h)
for v in count.values():
    if v == n:
        ans += 1
print(ans)
