import java.util.*;
 
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        int M = Integer.parseInt(sc.next());
        int[] K = new int[N];
        int[] f = new int[M];
        for(int i=0; i<N; i++) {
            K[i] = Integer.parseInt(sc.next());
            int a = 0;
            for(int j=0; j<K[i]; j++) {
                a = Integer.parseInt(sc.next());
                f[a-1]++;
            }
        }
        int count = 0;
        for(int x : f) {
            if(x == N) {
                count++;
            }
        }
        System.out.println(count);
    }
} import java.util.*; util.* java public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        int M = Integer.parseInt(sc.next());
        int[] K = new int[N];
        int[] f = new int[M];
        for(int i=0; i<N; i++) {
            K[i] = Integer.parseInt(sc.next());
            int a = 0;
            for(int j=0; j<K[i]; j++) {
                a = Integer.parseInt(sc.next());
                f[a-1]++;
            }
        }
        int count = 0;
        for(int x : f) {
            if(x == N) {
                count++;
            }
        }
        System.out.println(count);
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        int M = Integer.parseInt(sc.next());
        int[] K = new int[N];
        int[] f = new int[M];
        for(int i=0; i<N; i++) {
            K[i] = Integer.parseInt(sc.next());
            int a = 0;
            for(int j=0; j<K[i]; j++) {
                a = Integer.parseInt(sc.next());
                f[a-1]++;
            }
        }
        int count = 0;
        for(int x : f) {
            if(x == N) {
                count++;
            }
        }
        System.out.println(count);
    } main {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        int M = Integer.parseInt(sc.next());
        int[] K = new int[N];
        int[] f = new int[M];
        for(int i=0; i<N; i++) {
            K[i] = Integer.parseInt(sc.next());
            int a = 0;
            for(int j=0; j<K[i]; j++) {
                a = Integer.parseInt(sc.next());
                f[a-1]++;
            }
        }
        int count = 0;
        for(int x : f) {
            if(x == N) {
                count++;
            }
        }
        System.out.println(count);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int N = Integer.parseInt(sc.next()); N Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc int M = Integer.parseInt(sc.next()); M Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc int[] K = new int[N]; K new int[N] N int[] f = new int[M]; f new int[M] M for(int i=0; i<N; i++) {
            K[i] = Integer.parseInt(sc.next());
            int a = 0;
            for(int j=0; j<K[i]; j++) {
                a = Integer.parseInt(sc.next());
                f[a-1]++;
            }
        } int i=0; int i=0; i 0 i<N i N i++ i++ i {
            K[i] = Integer.parseInt(sc.next());
            int a = 0;
            for(int j=0; j<K[i]; j++) {
                a = Integer.parseInt(sc.next());
                f[a-1]++;
            }
        } {
            K[i] = Integer.parseInt(sc.next());
            int a = 0;
            for(int j=0; j<K[i]; j++) {
                a = Integer.parseInt(sc.next());
                f[a-1]++;
            }
        } K[i] = Integer.parseInt(sc.next()) K[i] K i Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc int a = 0; a 0 for(int j=0; j<K[i]; j++) {
                a = Integer.parseInt(sc.next());
                f[a-1]++;
            } int j=0; int j=0; j 0 j<K[i] j K[i] K i j++ j++ j {
                a = Integer.parseInt(sc.next());
                f[a-1]++;
            } {
                a = Integer.parseInt(sc.next());
                f[a-1]++;
            } a = Integer.parseInt(sc.next()) a Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc f[a-1]++ f[a-1] f a-1 a 1 int count = 0; count 0 for(int x : f) {
            if(x == N) {
                count++;
            }
        } int x f {
            if(x == N) {
                count++;
            }
        } {
            if(x == N) {
                count++;
            }
        } if(x == N) {
                count++;
            } x == N x N {
                count++;
            } count++ count System.out.println(count) System.out.println System.out System System.out count String[] args args public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        int M = Integer.parseInt(sc.next());
        int[] K = new int[N];
        int[] f = new int[M];
        for(int i=0; i<N; i++) {
            K[i] = Integer.parseInt(sc.next());
            int a = 0;
            for(int j=0; j<K[i]; j++) {
                a = Integer.parseInt(sc.next());
                f[a-1]++;
            }
        }
        int count = 0;
        for(int x : f) {
            if(x == N) {
                count++;
            }
        }
        System.out.println(count);
    }
} public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        int M = Integer.parseInt(sc.next());
        int[] K = new int[N];
        int[] f = new int[M];
        for(int i=0; i<N; i++) {
            K[i] = Integer.parseInt(sc.next());
            int a = 0;
            for(int j=0; j<K[i]; j++) {
                a = Integer.parseInt(sc.next());
                f[a-1]++;
            }
        }
        int count = 0;
        for(int x : f) {
            if(x == N) {
                count++;
            }
        }
        System.out.println(count);
    }
} Main
import java.util.*;
 
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        int M = Integer.parseInt(sc.next());
        int[] K = new int[N];
        int[] f = new int[M];
        for(int i=0; i<N; i++) {
            K[i] = Integer.parseInt(sc.next());
            int a = 0;
            for(int j=0; j<K[i]; j++) {
                a = Integer.parseInt(sc.next());
                f[a-1]++;
            }
        }
        int count = 0;
        for(int x : f) {
            if(x == N) {
                count++;
            }
        }
        System.out.println(count);
    }
}