import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        new Main().run();
    }

    private void run() {
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        int M = scanner.nextInt();
        Map<Integer, Integer> map = new HashMap<>();
        for(int i = 0; i < N; i++) {
            int k = scanner.nextInt();
            for(int j = 0; j < k; j++) {
                int a = scanner.nextInt();
                Integer val = map.get(a);
                if(val == null) {
                    map.put(a, 1);
                }else{
                    map.put(a, val + 1);
                }
            }
        }


        int ans = 0;
        for(Integer key : map.keySet()) {
            if(map.get(key) == N) {
                ans++;
            }
        }

        System.out.println(ans);

    }
} import java.util.HashMap; HashMap java.util import java.util.Map; Map java.util import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] args) {
        new Main().run();
    }

    private void run() {
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        int M = scanner.nextInt();
        Map<Integer, Integer> map = new HashMap<>();
        for(int i = 0; i < N; i++) {
            int k = scanner.nextInt();
            for(int j = 0; j < k; j++) {
                int a = scanner.nextInt();
                Integer val = map.get(a);
                if(val == null) {
                    map.put(a, 1);
                }else{
                    map.put(a, val + 1);
                }
            }
        }


        int ans = 0;
        for(Integer key : map.keySet()) {
            if(map.get(key) == N) {
                ans++;
            }
        }

        System.out.println(ans);

    }
} Main public static void main(String[] args) {
        new Main().run();
    } main {
        new Main().run();
    } new Main().run() new Main().run new Main() String[] args args private void run() {
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        int M = scanner.nextInt();
        Map<Integer, Integer> map = new HashMap<>();
        for(int i = 0; i < N; i++) {
            int k = scanner.nextInt();
            for(int j = 0; j < k; j++) {
                int a = scanner.nextInt();
                Integer val = map.get(a);
                if(val == null) {
                    map.put(a, 1);
                }else{
                    map.put(a, val + 1);
                }
            }
        }


        int ans = 0;
        for(Integer key : map.keySet()) {
            if(map.get(key) == N) {
                ans++;
            }
        }

        System.out.println(ans);

    } run {
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        int M = scanner.nextInt();
        Map<Integer, Integer> map = new HashMap<>();
        for(int i = 0; i < N; i++) {
            int k = scanner.nextInt();
            for(int j = 0; j < k; j++) {
                int a = scanner.nextInt();
                Integer val = map.get(a);
                if(val == null) {
                    map.put(a, 1);
                }else{
                    map.put(a, val + 1);
                }
            }
        }


        int ans = 0;
        for(Integer key : map.keySet()) {
            if(map.get(key) == N) {
                ans++;
            }
        }

        System.out.println(ans);

    } Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) int N = scanner.nextInt(); N scanner.nextInt() scanner.nextInt scanner int M = scanner.nextInt(); M scanner.nextInt() scanner.nextInt scanner Map<Integer, Integer> map = new HashMap<>(); map new HashMap<>() for(int i = 0; i < N; i++) {
            int k = scanner.nextInt();
            for(int j = 0; j < k; j++) {
                int a = scanner.nextInt();
                Integer val = map.get(a);
                if(val == null) {
                    map.put(a, 1);
                }else{
                    map.put(a, val + 1);
                }
            }
        } int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
            int k = scanner.nextInt();
            for(int j = 0; j < k; j++) {
                int a = scanner.nextInt();
                Integer val = map.get(a);
                if(val == null) {
                    map.put(a, 1);
                }else{
                    map.put(a, val + 1);
                }
            }
        } {
            int k = scanner.nextInt();
            for(int j = 0; j < k; j++) {
                int a = scanner.nextInt();
                Integer val = map.get(a);
                if(val == null) {
                    map.put(a, 1);
                }else{
                    map.put(a, val + 1);
                }
            }
        } int k = scanner.nextInt(); k scanner.nextInt() scanner.nextInt scanner for(int j = 0; j < k; j++) {
                int a = scanner.nextInt();
                Integer val = map.get(a);
                if(val == null) {
                    map.put(a, 1);
                }else{
                    map.put(a, val + 1);
                }
            } int j = 0; int j = 0; j 0 j < k j k j++ j++ j {
                int a = scanner.nextInt();
                Integer val = map.get(a);
                if(val == null) {
                    map.put(a, 1);
                }else{
                    map.put(a, val + 1);
                }
            } {
                int a = scanner.nextInt();
                Integer val = map.get(a);
                if(val == null) {
                    map.put(a, 1);
                }else{
                    map.put(a, val + 1);
                }
            } int a = scanner.nextInt(); a scanner.nextInt() scanner.nextInt scanner Integer val = map.get(a); val map.get(a) map.get map a if(val == null) {
                    map.put(a, 1);
                }else{
                    map.put(a, val + 1);
                } val == null val null {
                    map.put(a, 1);
                } map.put(a, 1) map.put map a 1 {
                    map.put(a, val + 1);
                } map.put(a, val + 1) map.put map a val + 1 val 1 int ans = 0; ans 0 for(Integer key : map.keySet()) {
            if(map.get(key) == N) {
                ans++;
            }
        } Integer key map.keySet() map.keySet map {
            if(map.get(key) == N) {
                ans++;
            }
        } {
            if(map.get(key) == N) {
                ans++;
            }
        } if(map.get(key) == N) {
                ans++;
            } map.get(key) == N map.get(key) map.get map key N {
                ans++;
            } ans++ ans System.out.println(ans) System.out.println System.out System System.out ans public class Main {
    public static void main(String[] args) {
        new Main().run();
    }

    private void run() {
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        int M = scanner.nextInt();
        Map<Integer, Integer> map = new HashMap<>();
        for(int i = 0; i < N; i++) {
            int k = scanner.nextInt();
            for(int j = 0; j < k; j++) {
                int a = scanner.nextInt();
                Integer val = map.get(a);
                if(val == null) {
                    map.put(a, 1);
                }else{
                    map.put(a, val + 1);
                }
            }
        }


        int ans = 0;
        for(Integer key : map.keySet()) {
            if(map.get(key) == N) {
                ans++;
            }
        }

        System.out.println(ans);

    }
} public class Main {
    public static void main(String[] args) {
        new Main().run();
    }

    private void run() {
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        int M = scanner.nextInt();
        Map<Integer, Integer> map = new HashMap<>();
        for(int i = 0; i < N; i++) {
            int k = scanner.nextInt();
            for(int j = 0; j < k; j++) {
                int a = scanner.nextInt();
                Integer val = map.get(a);
                if(val == null) {
                    map.put(a, 1);
                }else{
                    map.put(a, val + 1);
                }
            }
        }


        int ans = 0;
        for(Integer key : map.keySet()) {
            if(map.get(key) == N) {
                ans++;
            }
        }

        System.out.println(ans);

    }
} Main
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        new Main().run();
    }

    private void run() {
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        int M = scanner.nextInt();
        Map<Integer, Integer> map = new HashMap<>();
        for(int i = 0; i < N; i++) {
            int k = scanner.nextInt();
            for(int j = 0; j < k; j++) {
                int a = scanner.nextInt();
                Integer val = map.get(a);
                if(val == null) {
                    map.put(a, 1);
                }else{
                    map.put(a, val + 1);
                }
            }
        }


        int ans = 0;
        for(Integer key : map.keySet()) {
            if(map.get(key) == N) {
                ans++;
            }
        }

        System.out.println(ans);

    }
}