import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner stdin = new Scanner(System.in);
		int n = stdin.nextInt();
		int m = stdin.nextInt();
		int k = stdin.nextInt();
		List<Integer> memo = new ArrayList<Integer>();
		for(int i=0;i<k;i++) {
			memo.add(stdin.nextInt());
		}
		for(int j=0;j<n-1;j++) {
			List<Integer> a = new ArrayList<Integer>();
			k = stdin.nextInt();
			for(int l=0;l<k;l++) {
				a.add(stdin.nextInt());
			}
			memo.retainAll(a);
		}
		System.out.println(memo.size());
	}

} import java.util.ArrayList; ArrayList java.util import java.util.List; List java.util import java.util.Scanner; Scanner java.util public class Main {

	public static void main(String[] args) {
		Scanner stdin = new Scanner(System.in);
		int n = stdin.nextInt();
		int m = stdin.nextInt();
		int k = stdin.nextInt();
		List<Integer> memo = new ArrayList<Integer>();
		for(int i=0;i<k;i++) {
			memo.add(stdin.nextInt());
		}
		for(int j=0;j<n-1;j++) {
			List<Integer> a = new ArrayList<Integer>();
			k = stdin.nextInt();
			for(int l=0;l<k;l++) {
				a.add(stdin.nextInt());
			}
			memo.retainAll(a);
		}
		System.out.println(memo.size());
	}

} Main public static void main(String[] args) {
		Scanner stdin = new Scanner(System.in);
		int n = stdin.nextInt();
		int m = stdin.nextInt();
		int k = stdin.nextInt();
		List<Integer> memo = new ArrayList<Integer>();
		for(int i=0;i<k;i++) {
			memo.add(stdin.nextInt());
		}
		for(int j=0;j<n-1;j++) {
			List<Integer> a = new ArrayList<Integer>();
			k = stdin.nextInt();
			for(int l=0;l<k;l++) {
				a.add(stdin.nextInt());
			}
			memo.retainAll(a);
		}
		System.out.println(memo.size());
	} main {
		Scanner stdin = new Scanner(System.in);
		int n = stdin.nextInt();
		int m = stdin.nextInt();
		int k = stdin.nextInt();
		List<Integer> memo = new ArrayList<Integer>();
		for(int i=0;i<k;i++) {
			memo.add(stdin.nextInt());
		}
		for(int j=0;j<n-1;j++) {
			List<Integer> a = new ArrayList<Integer>();
			k = stdin.nextInt();
			for(int l=0;l<k;l++) {
				a.add(stdin.nextInt());
			}
			memo.retainAll(a);
		}
		System.out.println(memo.size());
	} Scanner stdin = new Scanner(System.in); stdin new Scanner(System.in) int n = stdin.nextInt(); n stdin.nextInt() stdin.nextInt stdin int m = stdin.nextInt(); m stdin.nextInt() stdin.nextInt stdin int k = stdin.nextInt(); k stdin.nextInt() stdin.nextInt stdin List<Integer> memo = new ArrayList<Integer>(); memo new ArrayList<Integer>() for(int i=0;i<k;i++) {
			memo.add(stdin.nextInt());
		} int i=0; int i=0; i 0 i<k i k i++ i++ i {
			memo.add(stdin.nextInt());
		} {
			memo.add(stdin.nextInt());
		} memo.add(stdin.nextInt()) memo.add memo stdin.nextInt() stdin.nextInt stdin for(int j=0;j<n-1;j++) {
			List<Integer> a = new ArrayList<Integer>();
			k = stdin.nextInt();
			for(int l=0;l<k;l++) {
				a.add(stdin.nextInt());
			}
			memo.retainAll(a);
		} int j=0; int j=0; j 0 j<n-1 j n-1 n 1 j++ j++ j {
			List<Integer> a = new ArrayList<Integer>();
			k = stdin.nextInt();
			for(int l=0;l<k;l++) {
				a.add(stdin.nextInt());
			}
			memo.retainAll(a);
		} {
			List<Integer> a = new ArrayList<Integer>();
			k = stdin.nextInt();
			for(int l=0;l<k;l++) {
				a.add(stdin.nextInt());
			}
			memo.retainAll(a);
		} List<Integer> a = new ArrayList<Integer>(); a new ArrayList<Integer>() k = stdin.nextInt() k stdin.nextInt() stdin.nextInt stdin for(int l=0;l<k;l++) {
				a.add(stdin.nextInt());
			} int l=0; int l=0; l 0 l<k l k l++ l++ l {
				a.add(stdin.nextInt());
			} {
				a.add(stdin.nextInt());
			} a.add(stdin.nextInt()) a.add a stdin.nextInt() stdin.nextInt stdin memo.retainAll(a) memo.retainAll memo a System.out.println(memo.size()) System.out.println System.out System System.out memo.size() memo.size memo String[] args args public class Main {

	public static void main(String[] args) {
		Scanner stdin = new Scanner(System.in);
		int n = stdin.nextInt();
		int m = stdin.nextInt();
		int k = stdin.nextInt();
		List<Integer> memo = new ArrayList<Integer>();
		for(int i=0;i<k;i++) {
			memo.add(stdin.nextInt());
		}
		for(int j=0;j<n-1;j++) {
			List<Integer> a = new ArrayList<Integer>();
			k = stdin.nextInt();
			for(int l=0;l<k;l++) {
				a.add(stdin.nextInt());
			}
			memo.retainAll(a);
		}
		System.out.println(memo.size());
	}

} public class Main {

	public static void main(String[] args) {
		Scanner stdin = new Scanner(System.in);
		int n = stdin.nextInt();
		int m = stdin.nextInt();
		int k = stdin.nextInt();
		List<Integer> memo = new ArrayList<Integer>();
		for(int i=0;i<k;i++) {
			memo.add(stdin.nextInt());
		}
		for(int j=0;j<n-1;j++) {
			List<Integer> a = new ArrayList<Integer>();
			k = stdin.nextInt();
			for(int l=0;l<k;l++) {
				a.add(stdin.nextInt());
			}
			memo.retainAll(a);
		}
		System.out.println(memo.size());
	}

} Main
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner stdin = new Scanner(System.in);
		int n = stdin.nextInt();
		int m = stdin.nextInt();
		int k = stdin.nextInt();
		List<Integer> memo = new ArrayList<Integer>();
		for(int i=0;i<k;i++) {
			memo.add(stdin.nextInt());
		}
		for(int j=0;j<n-1;j++) {
			List<Integer> a = new ArrayList<Integer>();
			k = stdin.nextInt();
			for(int l=0;l<k;l++) {
				a.add(stdin.nextInt());
			}
			memo.retainAll(a);
		}
		System.out.println(memo.size());
	}

}
