#!/usr/bin/env python3

k, m = list(map(int, input().split()))


set_ = set(range(1, m+1))


for i in range(k):
    _, *a = list(map(int, input().split()))
    set_ = set_ & set(a)


print(len(set_)) k, m = list(map(int, input().split())) k list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split m set_ = set(range(1, m+1)) set_ set(range(1, m+1)) set range(1, m+1) range 1 m+1 m 1 for i in range(k):
    _, *a = list(map(int, input().split()))
    set_ = set_ & set(a) i range(k) range k _, *a = list(map(int, input().split())) _ list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split *a a set_ = set_ & set(a) set_ set_ & set(a) set_ set(a) set a print(len(set_)) print len(set_) len set_ m = list(map(int, input().split())) list(map(int, input().split())) m _, *a = list(map(int, input().split())) list(map(int, input().split())) _ k, m = list(map(int, input().split())) list(map(int, input().split())) k set_ = set(range(1, m+1)) set(range(1, m+1)) set_ set_ = set_ & set(a) set_ & set(a) set_
#!/usr/bin/env python3

k, m = list(map(int, input().split()))


set_ = set(range(1, m+1))


for i in range(k):
    _, *a = list(map(int, input().split()))
    set_ = set_ & set(a)


print(len(set_))
