def main():
    n, m = map(int, input().split())
    food_list = [0] * m

    for _ in range(n):
        a_list = list(map(int, input().split()))
        for i in range(1, a_list[0] + 1):
            food_list[a_list[i] - 1] += 1

    cnt = 0
    for food in food_list:
        if food == n:
            cnt += 1
    print(cnt)


if __name__ == "__main__":
    main() def main():
    n, m = map(int, input().split())
    food_list = [0] * m

    for _ in range(n):
        a_list = list(map(int, input().split()))
        for i in range(1, a_list[0] + 1):
            food_list[a_list[i] - 1] += 1

    cnt = 0
    for food in food_list:
        if food == n:
            cnt += 1
    print(cnt) main n, m = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split m food_list = [0] * m food_list [0] * m [0] 0 m for _ in range(n):
        a_list = list(map(int, input().split()))
        for i in range(1, a_list[0] + 1):
            food_list[a_list[i] - 1] += 1

     _ range(n) range n a_list = list(map(int, input().split())) a_list list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split for i in range(1, a_list[0] + 1):
            food_list[a_list[i] - 1] += 1

     i range(1, a_list[0] + 1) range 1 a_list[0] + 1 a_list[0] a_list 0 1 food_list[a_list[i] - 1] += 1 food_list[a_list[i] - 1] food_list a_list[i] - 1 a_list[i] a_list i 1 1 cnt = 0 cnt 0 for food in food_list:
        if food == n:
            cnt += 1
     food food_list if food == n:
            cnt += 1
     food == n food n cnt += 1 cnt 1 print(cnt) print cnt if __name__ == "__main__":
    main() __name__ == "__main__" __name__ "__main__" main() main def main():
    n, m = map(int, input().split())
    food_list = [0] * m

    for _ in range(n):
        a_list = list(map(int, input().split()))
        for i in range(1, a_list[0] + 1):
            food_list[a_list[i] - 1] += 1

    cnt = 0
    for food in food_list:
        if food == n:
            cnt += 1
    print(cnt) def main():
    n, m = map(int, input().split())
    food_list = [0] * m

    for _ in range(n):
        a_list = list(map(int, input().split()))
        for i in range(1, a_list[0] + 1):
            food_list[a_list[i] - 1] += 1

    cnt = 0
    for food in food_list:
        if food == n:
            cnt += 1
    print(cnt) main
def main():
    n, m = map(int, input().split())
    food_list = [0] * m

    for _ in range(n):
        a_list = list(map(int, input().split()))
        for i in range(1, a_list[0] + 1):
            food_list[a_list[i] - 1] += 1

    cnt = 0
    for food in food_list:
        if food == n:
            cnt += 1
    print(cnt)


if __name__ == "__main__":
    main()
