import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline

n,m = map(int, input().split())
cnt = [0] * m
for _ in range(n):
    a = list(map(int, input().split()))
    for i in range(1, len(a)):
        a[i] -= 1
        cnt[a[i]] += 1

ans = 0
for c in cnt:
    if c == n:
        ans += 1
print(ans) import sys sys sys.setrecursionlimit(10**7) sys.setrecursionlimit sys setrecursionlimit 10**7 10 7 input = sys.stdin.readline input sys.stdin.readline sys.stdin sys stdin readline n,m = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split m cnt = [0] * m cnt [0] * m [0] 0 m for _ in range(n):
    a = list(map(int, input().split()))
    for i in range(1, len(a)):
        a[i] -= 1
        cnt[a[i]] += 1 _ range(n) range n a = list(map(int, input().split())) a list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split for i in range(1, len(a)):
        a[i] -= 1
        cnt[a[i]] += 1 i range(1, len(a)) range 1 len(a) len a a[i] -= 1 a[i] a i 1 cnt[a[i]] += 1 cnt[a[i]] cnt a[i] a i 1 ans = 0 ans 0 for c in cnt:
    if c == n:
        ans += 1 c cnt if c == n:
        ans += 1 c == n c n ans += 1 ans 1 print(ans) print ans cnt = [0] * m [0] * m cnt ans = 0 0 ans ans += 1 1 ans m = map(int, input().split()) map(int, input().split()) m n,m = map(int, input().split()) map(int, input().split()) n a = list(map(int, input().split())) list(map(int, input().split())) a input = sys.stdin.readline sys.stdin.readline input
import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline

n,m = map(int, input().split())
cnt = [0] * m
for _ in range(n):
    a = list(map(int, input().split()))
    for i in range(1, len(a)):
        a[i] -= 1
        cnt[a[i]] += 1

ans = 0
for c in cnt:
    if c == n:
        ans += 1
print(ans)
