import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Scanner;

class Main {

    static final int MOD = 1000000007;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        int[] cnt = new int[M];
        int ans = 0;
        for (int i = 0; i < N; i++) {
            int K = sc.nextInt();
            for (int j = 0; j < K; j++) {
                cnt[sc.nextInt()-1]++;
            }
        }
        for (int i = 0; i < M; i++) {
            if (cnt[i] == N)
                ans++;
        }
        System.out.println(ans);
    }
} import java.math.BigDecimal; BigDecimal java.math import java.math.BigInteger; BigInteger java.math import java.util.ArrayList; ArrayList java.util import java.util.Collection; Collection java.util import java.util.Collections; Collections java.util import java.util.Scanner; Scanner java.util class Main {

    static final int MOD = 1000000007;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        int[] cnt = new int[M];
        int ans = 0;
        for (int i = 0; i < N; i++) {
            int K = sc.nextInt();
            for (int j = 0; j < K; j++) {
                cnt[sc.nextInt()-1]++;
            }
        }
        for (int i = 0; i < M; i++) {
            if (cnt[i] == N)
                ans++;
        }
        System.out.println(ans);
    }
} Main static final int MOD = 1000000007; MOD 1000000007 public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        int[] cnt = new int[M];
        int ans = 0;
        for (int i = 0; i < N; i++) {
            int K = sc.nextInt();
            for (int j = 0; j < K; j++) {
                cnt[sc.nextInt()-1]++;
            }
        }
        for (int i = 0; i < M; i++) {
            if (cnt[i] == N)
                ans++;
        }
        System.out.println(ans);
    } main {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        int[] cnt = new int[M];
        int ans = 0;
        for (int i = 0; i < N; i++) {
            int K = sc.nextInt();
            for (int j = 0; j < K; j++) {
                cnt[sc.nextInt()-1]++;
            }
        }
        for (int i = 0; i < M; i++) {
            if (cnt[i] == N)
                ans++;
        }
        System.out.println(ans);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int N = sc.nextInt(); N sc.nextInt() sc.nextInt sc int M = sc.nextInt(); M sc.nextInt() sc.nextInt sc int[] cnt = new int[M]; cnt new int[M] M int ans = 0; ans 0 for (int i = 0; i < N; i++) {
            int K = sc.nextInt();
            for (int j = 0; j < K; j++) {
                cnt[sc.nextInt()-1]++;
            }
        } int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
            int K = sc.nextInt();
            for (int j = 0; j < K; j++) {
                cnt[sc.nextInt()-1]++;
            }
        } {
            int K = sc.nextInt();
            for (int j = 0; j < K; j++) {
                cnt[sc.nextInt()-1]++;
            }
        } int K = sc.nextInt(); K sc.nextInt() sc.nextInt sc for (int j = 0; j < K; j++) {
                cnt[sc.nextInt()-1]++;
            } int j = 0; int j = 0; j 0 j < K j K j++ j++ j {
                cnt[sc.nextInt()-1]++;
            } {
                cnt[sc.nextInt()-1]++;
            } cnt[sc.nextInt()-1]++ cnt[sc.nextInt()-1] cnt sc.nextInt()-1 sc.nextInt() sc.nextInt sc 1 for (int i = 0; i < M; i++) {
            if (cnt[i] == N)
                ans++;
        } int i = 0; int i = 0; i 0 i < M i M i++ i++ i {
            if (cnt[i] == N)
                ans++;
        } {
            if (cnt[i] == N)
                ans++;
        } if (cnt[i] == N)
                ans++; cnt[i] == N cnt[i] cnt i N ans++ ans System.out.println(ans) System.out.println System.out System System.out ans String[] args args
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Scanner;

class Main {

    static final int MOD = 1000000007;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        int[] cnt = new int[M];
        int ans = 0;
        for (int i = 0; i < N; i++) {
            int K = sc.nextInt();
            for (int j = 0; j < K; j++) {
                cnt[sc.nextInt()-1]++;
            }
        }
        for (int i = 0; i < M; i++) {
            if (cnt[i] == N)
                ans++;
        }
        System.out.println(ans);
    }
}