from collections import Counter


def mapt(fn, *args):
    return tuple(map(fn, *args))


def Input():
    return mapt(int, input().split(" "))


def main():
    n, m = Input()
    data = [Input()[1:] for _ in range(n)]
    d = Counter(num for row in data for num in row)
    print(sum(value == n for value in d.values()))


main() from collections import Counter def mapt(fn, *args):
    return tuple(map(fn, *args)) mapt return tuple(map(fn, *args)) tuple(map(fn, *args)) tuple map(fn, *args) map fn *args args fn fn *args def Input():
    return mapt(int, input().split(" ")) Input return mapt(int, input().split(" ")) mapt(int, input().split(" ")) mapt int input().split(" ") ().split () input split " " def main():
    n, m = Input()
    data = [Input()[1:] for _ in range(n)]
    d = Counter(num for row in data for num in row)
    print(sum(value == n for value in d.values())) main n, m = Input() n Input() Input m Input()[1:] for _ in range(n) for _ in range(n) _ range(n) range n for _ in range(n) Input()[1:] () Input 1: 1 data = [Input()[1:] for _ in range(n)] data [Input()[1:] for _ in range(n)] d = Counter(num for row in data for num in row) d Counter(num for row in data for num in row) Counter num print(sum(value == n for value in d.values())) print sum(value == n for value in d.values()) sum value == n value n main() main def Input():
    return mapt(int, input().split(" ")) def Input():
    return mapt(int, input().split(" ")) Input def mapt(fn, *args):
    return tuple(map(fn, *args)) def mapt(fn, *args):
    return tuple(map(fn, *args)) mapt def main():
    n, m = Input()
    data = [Input()[1:] for _ in range(n)]
    d = Counter(num for row in data for num in row)
    print(sum(value == n for value in d.values())) def main():
    n, m = Input()
    data = [Input()[1:] for _ in range(n)]
    d = Counter(num for row in data for num in row)
    print(sum(value == n for value in d.values())) main
from collections import Counter


def mapt(fn, *args):
    return tuple(map(fn, *args))


def Input():
    return mapt(int, input().split(" "))


def main():
    n, m = Input()
    data = [Input()[1:] for _ in range(n)]
    d = Counter(num for row in data for num in row)
    print(sum(value == n for value in d.values()))


main()