import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


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

    ans = 0
    for i, v in enumerate(vec, 1):
        if v == N:
            ans += 1

    print(ans)
    return


if __name__ == '__main__':
    main() import sys sys read = sys.stdin.read read sys.stdin.read sys.stdin sys stdin read readline = sys.stdin.readline readline sys.stdin.readline sys.stdin sys stdin readline readlines = sys.stdin.readlines readlines sys.stdin.readlines sys.stdin sys stdin readlines sys.setrecursionlimit(10 ** 9) sys.setrecursionlimit sys setrecursionlimit 10 ** 9 10 9 INF = 1 << 60 INF 1 << 60 1 60 MOD = 1000000007 MOD 1000000007 def main():
    N, M = map(int, readline().split())
    vec = [0] * M
    for _ in range(N):
        K, *A = map(int, readline().split())
        for a in A:
            vec[a - 1] += 1

    ans = 0
    for i, v in enumerate(vec, 1):
        if v == N:
            ans += 1

    print(ans)
    return main N, M = map(int, readline().split()) N map(int, readline().split()) map int readline().split() ().split () readline split M vec = [0] * M vec [0] * M [0] 0 M for _ in range(N):
        K, *A = map(int, readline().split())
        for a in A:
            vec[a - 1] += 1

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

     a A vec[a - 1] += 1 vec[a - 1] vec a - 1 a 1 1 ans = 0 ans 0 for i, v in enumerate(vec, 1):
        if v == N:
            ans += 1

     i v enumerate(vec, 1) enumerate vec 1 if v == N:
            ans += 1

     v == N v N ans += 1 ans 1 print(ans) print ans return if __name__ == '__main__':
    main() __name__ == '__main__' __name__ '__main__' main() main read = sys.stdin.read sys.stdin.read read INF = 1 << 60 1 << 60 INF readlines = sys.stdin.readlines sys.stdin.readlines readlines def main():
    N, M = map(int, readline().split())
    vec = [0] * M
    for _ in range(N):
        K, *A = map(int, readline().split())
        for a in A:
            vec[a - 1] += 1

    ans = 0
    for i, v in enumerate(vec, 1):
        if v == N:
            ans += 1

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

    ans = 0
    for i, v in enumerate(vec, 1):
        if v == N:
            ans += 1

    print(ans)
    return main MOD = 1000000007 1000000007 MOD readline = sys.stdin.readline sys.stdin.readline readline
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


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

    ans = 0
    for i, v in enumerate(vec, 1):
        if v == N:
            ans += 1

    print(ans)
    return


if __name__ == '__main__':
    main()
