N, M = input().split(' ')
N = int(N)
M = int(M)
K1 = input().split(' ')
Like = [int(K1[i]) for i in range(1, len(K1))]
Like = set(Like)
for i in range(N-1):
  K = input().split(' ')
  K = [int(K[i]) for i in range(1, int(K[0])+1)]
  K = set(K)
  Like &= K
print(len(Like)) N, M = input().split(' ') N input().split(' ') ().split () input split ' ' M N = int(N) N int(N) int N M = int(M) M int(M) int M K1 = input().split(' ') K1 input().split(' ') ().split () input split ' ' int(K1[i]) for i in range(1, len(K1)) for i in range(1, len(K1)) i range(1, len(K1)) range 1 len(K1) len K1 for i in range(1, len(K1)) int(K1[i]) int K1[i] K1 i Like = [int(K1[i]) for i in range(1, len(K1))] Like [int(K1[i]) for i in range(1, len(K1))] Like = set(Like) Like set(Like) set Like for i in range(N-1):
  K = input().split(' ')
  K = [int(K[i]) for i in range(1, int(K[0])+1)]
  K = set(K)
  Like &= K i range(N-1) range N-1 N 1 K = input().split(' ') K input().split(' ') ().split () input split ' ' int(K[i]) for i in range(1, int(K[0])+1) for i in range(1, int(K[0])+1) i range(1, int(K[0])+1) range 1 int(K[0])+1 int(K[0]) int K[0] K 0 1 for i in range(1, int(K[0])+1) int(K[i]) int K[i] K i K = [int(K[i]) for i in range(1, int(K[0])+1)] K [int(K[i]) for i in range(1, int(K[0])+1)] K = set(K) K set(K) set K Like &= K Like K print(len(Like)) print len(Like) len Like M = int(M) int(M) M Like = set(Like) set(Like) Like K1 = input().split(' ') input().split(' ') K1 M = input().split(' ') input().split(' ') M K = input().split(' ') input().split(' ') K K = set(K) set(K) K N = int(N) int(N) N Like &= K K Like Like = [int(K1[i]) for i in range(1, len(K1))] [int(K1[i]) for i in range(1, len(K1))] Like K = [int(K[i]) for i in range(1, int(K[0])+1)] [int(K[i]) for i in range(1, int(K[0])+1)] K N, M = input().split(' ') input().split(' ') N
N, M = input().split(' ')
N = int(N)
M = int(M)
K1 = input().split(' ')
Like = [int(K1[i]) for i in range(1, len(K1))]
Like = set(Like)
for i in range(N-1):
  K = input().split(' ')
  K = [int(K[i]) for i in range(1, int(K[0])+1)]
  K = set(K)
  Like &= K
print(len(Like))