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

n, m = map(int, input().split())
fav = set(range(1, m+1))
for _ in range(n):
    a = set(list(map(int, input().split()))[1:])
    fav = fav.intersection(a)

print(len(fav)) import sys sys input = sys.stdin.readline input sys.stdin.readline sys.stdin sys stdin readline sys.setrecursionlimit(10 ** 7) sys.setrecursionlimit sys setrecursionlimit 10 ** 7 10 7 n, m = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split m fav = set(range(1, m+1)) fav set(range(1, m+1)) set range(1, m+1) range 1 m+1 m 1 for _ in range(n):
    a = set(list(map(int, input().split()))[1:])
    fav = fav.intersection(a) _ range(n) range n a = set(list(map(int, input().split()))[1:]) a set(list(map(int, input().split()))[1:]) set list(map(int, input().split()))[1:] (map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split 1: 1 fav = fav.intersection(a) fav fav.intersection(a) fav.intersection fav intersection a print(len(fav)) print len(fav) len fav input = sys.stdin.readline sys.stdin.readline input a = set(list(map(int, input().split()))[1:]) set(list(map(int, input().split()))[1:]) a m = map(int, input().split()) map(int, input().split()) m n, m = map(int, input().split()) map(int, input().split()) n fav = set(range(1, m+1)) set(range(1, m+1)) fav fav = fav.intersection(a) fav.intersection(a) fav
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

n, m = map(int, input().split())
fav = set(range(1, m+1))
for _ in range(n):
    a = set(list(map(int, input().split()))[1:])
    fav = fav.intersection(a)

print(len(fav))
