import sys

input = sys.stdin.readline


def main():
    N, M = map(int, input().split())
    like_food = [0] * M
    for _ in range(N):
        _, *A = map(int, input().split())
        for a in A:
            like_food[a - 1] += 1

    ans = like_food.count(N)
    print(ans)


if __name__ == "__main__":
    main() import sys sys input = sys.stdin.readline input sys.stdin.readline sys.stdin sys stdin readline def main():
    N, M = map(int, input().split())
    like_food = [0] * M
    for _ in range(N):
        _, *A = map(int, input().split())
        for a in A:
            like_food[a - 1] += 1

    ans = like_food.count(N)
    print(ans) main N, M = map(int, input().split()) N map(int, input().split()) map int input().split() ().split () input split M like_food = [0] * M like_food [0] * M [0] 0 M for _ in range(N):
        _, *A = map(int, input().split())
        for a in A:
            like_food[a - 1] += 1

     _ range(N) range N _, *A = map(int, input().split()) _ map(int, input().split()) map int input().split() ().split () input split *A A for a in A:
            like_food[a - 1] += 1

     a A like_food[a - 1] += 1 like_food[a - 1] like_food a - 1 a 1 1 ans = like_food.count(N) ans like_food.count(N) like_food.count like_food count N print(ans) print ans if __name__ == "__main__":
    main() __name__ == "__main__" __name__ "__main__" main() main def main():
    N, M = map(int, input().split())
    like_food = [0] * M
    for _ in range(N):
        _, *A = map(int, input().split())
        for a in A:
            like_food[a - 1] += 1

    ans = like_food.count(N)
    print(ans) def main():
    N, M = map(int, input().split())
    like_food = [0] * M
    for _ in range(N):
        _, *A = map(int, input().split())
        for a in A:
            like_food[a - 1] += 1

    ans = like_food.count(N)
    print(ans) main input = sys.stdin.readline sys.stdin.readline input
import sys

input = sys.stdin.readline


def main():
    N, M = map(int, input().split())
    like_food = [0] * M
    for _ in range(N):
        _, *A = map(int, input().split())
        for a in A:
            like_food[a - 1] += 1

    ans = like_food.count(N)
    print(ans)


if __name__ == "__main__":
    main()
