import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

n, m = map(int, readline().split())
ka = []
ans = set(str(i+1) for i in range(m))

for _ in range(n):
    ka = input().split()
    ans = ans & set(ka[1:])
    
print(len(ans)) import sys sys read = sys.stdin.buffer.read read sys.stdin.buffer.read sys.stdin.buffer sys.stdin sys stdin buffer read readline = sys.stdin.buffer.readline readline sys.stdin.buffer.readline sys.stdin.buffer sys.stdin sys stdin buffer readline readlines = sys.stdin.buffer.readlines readlines sys.stdin.buffer.readlines sys.stdin.buffer sys.stdin sys stdin buffer readlines n, m = map(int, readline().split()) n map(int, readline().split()) map int readline().split() ().split () readline split m ka = [] ka [] ans = set(str(i+1) for i in range(m)) ans set(str(i+1) for i in range(m)) set str(i+1) str i+1 i 1 for _ in range(n):
    ka = input().split()
    ans = ans & set(ka[1:])
     _ range(n) range n ka = input().split() ka input().split() ().split () input split ans = ans & set(ka[1:]) ans ans & set(ka[1:]) ans set(ka[1:]) set ka[1:] ka 1: 1 print(len(ans)) print len(ans) len ans ka = [] [] ka ans = set(str(i+1) for i in range(m)) set(str(i+1) for i in range(m)) ans m = map(int, readline().split()) map(int, readline().split()) m ka = input().split() input().split() ka ans = ans & set(ka[1:]) ans & set(ka[1:]) ans readlines = sys.stdin.buffer.readlines sys.stdin.buffer.readlines readlines n, m = map(int, readline().split()) map(int, readline().split()) n read = sys.stdin.buffer.read sys.stdin.buffer.read read readline = sys.stdin.buffer.readline sys.stdin.buffer.readline readline
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

n, m = map(int, readline().split())
ka = []
ans = set(str(i+1) for i in range(m))

for _ in range(n):
    ka = input().split()
    ans = ans & set(ka[1:])
    
print(len(ans))