#-*-coding:utf-8-*-
import sys
input=sys.stdin.readline

def main():
    interview=[]
    n,m = map(int,input().split())
    interview=[list(map(int,input().split())) for _ in range(n)]
    set_data={}

    for data in interview:
        if len(set_data)==0:
            set_data  = set(data[1:])
        else:
            set_data=set_data & set(data[1:])
    print(len(set_data))


if __name__=="__main__":
    main() import sys sys input=sys.stdin.readline input sys.stdin.readline sys.stdin sys stdin readline def main():
    interview=[]
    n,m = map(int,input().split())
    interview=[list(map(int,input().split())) for _ in range(n)]
    set_data={}

    for data in interview:
        if len(set_data)==0:
            set_data  = set(data[1:])
        else:
            set_data=set_data & set(data[1:])
    print(len(set_data)) main interview=[] interview [] 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 interview=[list(map(int,input().split())) for _ in range(n)] interview [list(map(int,input().split())) for _ in range(n)] set_data={} set_data {} for data in interview:
        if len(set_data)==0:
            set_data  = set(data[1:])
        else:
            set_data=set_data & set(data[1:])
     data interview if len(set_data)==0:
            set_data  = set(data[1:])
        else:
            set_data=set_data & set(data[1:])
     len(set_data)==0 len(set_data) len set_data 0 set_data  = set(data[1:]) set_data set(data[1:]) set data[1:] data 1: 1 set_data=set_data & set(data[1:]) set_data set_data & set(data[1:]) set_data set(data[1:]) set data[1:] data 1: 1 print(len(set_data)) print len(set_data) len set_data if __name__=="__main__":
    main() __name__=="__main__" __name__ "__main__" main() main input=sys.stdin.readline sys.stdin.readline input def main():
    interview=[]
    n,m = map(int,input().split())
    interview=[list(map(int,input().split())) for _ in range(n)]
    set_data={}

    for data in interview:
        if len(set_data)==0:
            set_data  = set(data[1:])
        else:
            set_data=set_data & set(data[1:])
    print(len(set_data)) def main():
    interview=[]
    n,m = map(int,input().split())
    interview=[list(map(int,input().split())) for _ in range(n)]
    set_data={}

    for data in interview:
        if len(set_data)==0:
            set_data  = set(data[1:])
        else:
            set_data=set_data & set(data[1:])
    print(len(set_data)) main
#-*-coding:utf-8-*-
import sys
input=sys.stdin.readline

def main():
    interview=[]
    n,m = map(int,input().split())
    interview=[list(map(int,input().split())) for _ in range(n)]
    set_data={}

    for data in interview:
        if len(set_data)==0:
            set_data  = set(data[1:])
        else:
            set_data=set_data & set(data[1:])
    print(len(set_data))


if __name__=="__main__":
    main()