import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np

rr = lambda: sys.stdin.readline().rstrip()
rs = lambda: sys.stdin.readline().split()
ri = lambda: int(sys.stdin.readline())
rm = lambda: map(int, sys.stdin.readline().split())
rl = lambda: list(map(int, sys.stdin.readline().split()))
inf = float('inf')
mod = 10**9 + 7

n, m = rm()
li = [0]*m
for _ in range(n):
  for i in rl()[1:]:
    li[i-1]+=1
print(sum([i==n for i in li])) import sys sys import math math import itertools itertools import collections collections import heapq heapq import re re import numpy as np numpy rr = lambda: sys.stdin.readline().rstrip() rr lambda: sys.stdin.readline().rstrip() sys.stdin.readline().rstrip() sys.stdin.readline().rstrip sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline rstrip rs = lambda: sys.stdin.readline().split() rs lambda: sys.stdin.readline().split() sys.stdin.readline().split() sys.stdin.readline().split sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline split ri = lambda: int(sys.stdin.readline()) ri lambda: int(sys.stdin.readline()) int(sys.stdin.readline()) int sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline rm = lambda: map(int, sys.stdin.readline().split()) rm lambda: map(int, sys.stdin.readline().split()) map(int, sys.stdin.readline().split()) map int sys.stdin.readline().split() sys.stdin.readline().split sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline split rl = lambda: list(map(int, sys.stdin.readline().split())) rl lambda: list(map(int, sys.stdin.readline().split())) list(map(int, sys.stdin.readline().split())) list map(int, sys.stdin.readline().split()) map int sys.stdin.readline().split() sys.stdin.readline().split sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline split inf = float('inf') inf float('inf') float 'inf' mod = 10**9 + 7 mod 10**9 + 7 10**9 10 9 7 n, m = rm() n rm() rm m li = [0]*m li [0]*m [0] 0 m for _ in range(n):
  for i in rl()[1:]:
    li[i-1]+=1 _ range(n) range n for i in rl()[1:]:
    li[i-1]+=1 i rl()[1:] () rl 1: 1 li[i-1]+=1 li[i-1] li i-1 i 1 1 i==n for i in li for i in li i li for i in li i==n i n print(sum([i==n for i in li])) print sum([i==n for i in li]) sum [i==n for i in li] ri = lambda: int(sys.stdin.readline()) lambda: int(sys.stdin.readline()) ri inf = float('inf') float('inf') inf rs = lambda: sys.stdin.readline().split() lambda: sys.stdin.readline().split() rs mod = 10**9 + 7 10**9 + 7 mod rm = lambda: map(int, sys.stdin.readline().split()) lambda: map(int, sys.stdin.readline().split()) rm rl = lambda: list(map(int, sys.stdin.readline().split())) lambda: list(map(int, sys.stdin.readline().split())) rl n, m = rm() rm() n rr = lambda: sys.stdin.readline().rstrip() lambda: sys.stdin.readline().rstrip() rr m = rm() rm() m li = [0]*m [0]*m li
import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np

rr = lambda: sys.stdin.readline().rstrip()
rs = lambda: sys.stdin.readline().split()
ri = lambda: int(sys.stdin.readline())
rm = lambda: map(int, sys.stdin.readline().split())
rl = lambda: list(map(int, sys.stdin.readline().split()))
inf = float('inf')
mod = 10**9 + 7

n, m = rm()
li = [0]*m
for _ in range(n):
  for i in rl()[1:]:
    li[i-1]+=1
print(sum([i==n for i in li]))