def main():
    n,m=map(int,input().split())
    k = [list(map(int,input().split())) for _ in range(n)]
    f = [0] * m
    for i in k:
        for j in i[1:]:
            f[j-1] += 1
    print(f.count(n))
    
if __name__ == "__main__":
    main() def main():
    n,m=map(int,input().split())
    k = [list(map(int,input().split())) for _ in range(n)]
    f = [0] * m
    for i in k:
        for j in i[1:]:
            f[j-1] += 1
    print(f.count(n))
     main n,m=map(int,input().split()) n map(int,input().split()) map int input().split() ().split () input split m list(map(int,input().split())) for _ in range(n) for _ in range(n) _ range(n) range n for _ in range(n) list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split k = [list(map(int,input().split())) for _ in range(n)] k [list(map(int,input().split())) for _ in range(n)] f = [0] * m f [0] * m [0] 0 m for i in k:
        for j in i[1:]:
            f[j-1] += 1
     i k for j in i[1:]:
            f[j-1] += 1
     j i[1:] i 1: 1 f[j-1] += 1 f[j-1] f j-1 j 1 1 print(f.count(n)) print f.count(n) f.count f count n if __name__ == "__main__":
    main() __name__ == "__main__" __name__ "__main__" main() main def main():
    n,m=map(int,input().split())
    k = [list(map(int,input().split())) for _ in range(n)]
    f = [0] * m
    for i in k:
        for j in i[1:]:
            f[j-1] += 1
    print(f.count(n))
     def main():
    n,m=map(int,input().split())
    k = [list(map(int,input().split())) for _ in range(n)]
    f = [0] * m
    for i in k:
        for j in i[1:]:
            f[j-1] += 1
    print(f.count(n))
     main
def main():
    n,m=map(int,input().split())
    k = [list(map(int,input().split())) for _ in range(n)]
    f = [0] * m
    for i in k:
        for j in i[1:]:
            f[j-1] += 1
    print(f.count(n))
    
if __name__ == "__main__":
    main()