import static java.lang.Integer.*;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st;
		st = new StringTokenizer(br.readLine());
		int N = parseInt(st.nextToken());
		int M = parseInt(st.nextToken());
		boolean[] foods = new boolean[M];

		for(int i=0;i<N;i++) {
			st = new StringTokenizer(br.readLine());
			int K = parseInt(st.nextToken());

			List<Integer> indexList= new ArrayList<>();

			for(int j=0;j<K;j++) {
				int n = parseInt(st.nextToken());
				if(i==0) {
					foods[n-1] = true;
				}
				indexList.add(n);
			}

			for(int x=0;x<foods.length;x++) {
				if(foods[x] == true) {
					if(indexList.indexOf(x+1) == -1) {
						foods[x] = false;
					}
				}
			}

		}

		int sum = 0;
		for(int x=0;x<foods.length;x++) {
			if(foods[x] == true) {
				sum ++;
			}
		}

		System.out.println(sum);

	}
} import static java.lang.Integer.*; import static java.lang.Integer.*; import static java.lang.Integer.*; import java.io.BufferedReader; BufferedReader java.io import java.io.IOException; IOException java.io import java.io.InputStreamReader; InputStreamReader java.io import java.util.ArrayList; ArrayList java.util import java.util.List; List java.util import java.util.StringTokenizer; StringTokenizer java.util public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st;
		st = new StringTokenizer(br.readLine());
		int N = parseInt(st.nextToken());
		int M = parseInt(st.nextToken());
		boolean[] foods = new boolean[M];

		for(int i=0;i<N;i++) {
			st = new StringTokenizer(br.readLine());
			int K = parseInt(st.nextToken());

			List<Integer> indexList= new ArrayList<>();

			for(int j=0;j<K;j++) {
				int n = parseInt(st.nextToken());
				if(i==0) {
					foods[n-1] = true;
				}
				indexList.add(n);
			}

			for(int x=0;x<foods.length;x++) {
				if(foods[x] == true) {
					if(indexList.indexOf(x+1) == -1) {
						foods[x] = false;
					}
				}
			}

		}

		int sum = 0;
		for(int x=0;x<foods.length;x++) {
			if(foods[x] == true) {
				sum ++;
			}
		}

		System.out.println(sum);

	}
} Main public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st;
		st = new StringTokenizer(br.readLine());
		int N = parseInt(st.nextToken());
		int M = parseInt(st.nextToken());
		boolean[] foods = new boolean[M];

		for(int i=0;i<N;i++) {
			st = new StringTokenizer(br.readLine());
			int K = parseInt(st.nextToken());

			List<Integer> indexList= new ArrayList<>();

			for(int j=0;j<K;j++) {
				int n = parseInt(st.nextToken());
				if(i==0) {
					foods[n-1] = true;
				}
				indexList.add(n);
			}

			for(int x=0;x<foods.length;x++) {
				if(foods[x] == true) {
					if(indexList.indexOf(x+1) == -1) {
						foods[x] = false;
					}
				}
			}

		}

		int sum = 0;
		for(int x=0;x<foods.length;x++) {
			if(foods[x] == true) {
				sum ++;
			}
		}

		System.out.println(sum);

	} main {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st;
		st = new StringTokenizer(br.readLine());
		int N = parseInt(st.nextToken());
		int M = parseInt(st.nextToken());
		boolean[] foods = new boolean[M];

		for(int i=0;i<N;i++) {
			st = new StringTokenizer(br.readLine());
			int K = parseInt(st.nextToken());

			List<Integer> indexList= new ArrayList<>();

			for(int j=0;j<K;j++) {
				int n = parseInt(st.nextToken());
				if(i==0) {
					foods[n-1] = true;
				}
				indexList.add(n);
			}

			for(int x=0;x<foods.length;x++) {
				if(foods[x] == true) {
					if(indexList.indexOf(x+1) == -1) {
						foods[x] = false;
					}
				}
			}

		}

		int sum = 0;
		for(int x=0;x<foods.length;x++) {
			if(foods[x] == true) {
				sum ++;
			}
		}

		System.out.println(sum);

	} BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) StringTokenizer st; st st = new StringTokenizer(br.readLine()) st new StringTokenizer(br.readLine()) int N = parseInt(st.nextToken()); N parseInt(st.nextToken()) parseInt st.nextToken() st.nextToken st int M = parseInt(st.nextToken()); M parseInt(st.nextToken()) parseInt st.nextToken() st.nextToken st boolean[] foods = new boolean[M]; foods new boolean[M] M for(int i=0;i<N;i++) {
			st = new StringTokenizer(br.readLine());
			int K = parseInt(st.nextToken());

			List<Integer> indexList= new ArrayList<>();

			for(int j=0;j<K;j++) {
				int n = parseInt(st.nextToken());
				if(i==0) {
					foods[n-1] = true;
				}
				indexList.add(n);
			}

			for(int x=0;x<foods.length;x++) {
				if(foods[x] == true) {
					if(indexList.indexOf(x+1) == -1) {
						foods[x] = false;
					}
				}
			}

		} int i=0; int i=0; i 0 i<N i N i++ i++ i {
			st = new StringTokenizer(br.readLine());
			int K = parseInt(st.nextToken());

			List<Integer> indexList= new ArrayList<>();

			for(int j=0;j<K;j++) {
				int n = parseInt(st.nextToken());
				if(i==0) {
					foods[n-1] = true;
				}
				indexList.add(n);
			}

			for(int x=0;x<foods.length;x++) {
				if(foods[x] == true) {
					if(indexList.indexOf(x+1) == -1) {
						foods[x] = false;
					}
				}
			}

		} {
			st = new StringTokenizer(br.readLine());
			int K = parseInt(st.nextToken());

			List<Integer> indexList= new ArrayList<>();

			for(int j=0;j<K;j++) {
				int n = parseInt(st.nextToken());
				if(i==0) {
					foods[n-1] = true;
				}
				indexList.add(n);
			}

			for(int x=0;x<foods.length;x++) {
				if(foods[x] == true) {
					if(indexList.indexOf(x+1) == -1) {
						foods[x] = false;
					}
				}
			}

		} st = new StringTokenizer(br.readLine()) st new StringTokenizer(br.readLine()) int K = parseInt(st.nextToken()); K parseInt(st.nextToken()) parseInt st.nextToken() st.nextToken st List<Integer> indexList= new ArrayList<>(); indexList new ArrayList<>() for(int j=0;j<K;j++) {
				int n = parseInt(st.nextToken());
				if(i==0) {
					foods[n-1] = true;
				}
				indexList.add(n);
			} int j=0; int j=0; j 0 j<K j K j++ j++ j {
				int n = parseInt(st.nextToken());
				if(i==0) {
					foods[n-1] = true;
				}
				indexList.add(n);
			} {
				int n = parseInt(st.nextToken());
				if(i==0) {
					foods[n-1] = true;
				}
				indexList.add(n);
			} int n = parseInt(st.nextToken()); n parseInt(st.nextToken()) parseInt st.nextToken() st.nextToken st if(i==0) {
					foods[n-1] = true;
				} i==0 i 0 {
					foods[n-1] = true;
				} foods[n-1] = true foods[n-1] foods n-1 n 1 true indexList.add(n) indexList.add indexList n for(int x=0;x<foods.length;x++) {
				if(foods[x] == true) {
					if(indexList.indexOf(x+1) == -1) {
						foods[x] = false;
					}
				}
			} int x=0; int x=0; x 0 x<foods.length x foods.length foods foods.length x++ x++ x {
				if(foods[x] == true) {
					if(indexList.indexOf(x+1) == -1) {
						foods[x] = false;
					}
				}
			} {
				if(foods[x] == true) {
					if(indexList.indexOf(x+1) == -1) {
						foods[x] = false;
					}
				}
			} if(foods[x] == true) {
					if(indexList.indexOf(x+1) == -1) {
						foods[x] = false;
					}
				} foods[x] == true foods[x] foods x true {
					if(indexList.indexOf(x+1) == -1) {
						foods[x] = false;
					}
				} if(indexList.indexOf(x+1) == -1) {
						foods[x] = false;
					} indexList.indexOf(x+1) == -1 indexList.indexOf(x+1) indexList.indexOf indexList x+1 x 1 -1 1 {
						foods[x] = false;
					} foods[x] = false foods[x] foods x false int sum = 0; sum 0 for(int x=0;x<foods.length;x++) {
			if(foods[x] == true) {
				sum ++;
			}
		} int x=0; int x=0; x 0 x<foods.length x foods.length foods foods.length x++ x++ x {
			if(foods[x] == true) {
				sum ++;
			}
		} {
			if(foods[x] == true) {
				sum ++;
			}
		} if(foods[x] == true) {
				sum ++;
			} foods[x] == true foods[x] foods x true {
				sum ++;
			} sum ++ sum System.out.println(sum) System.out.println System.out System System.out sum String[] args args public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st;
		st = new StringTokenizer(br.readLine());
		int N = parseInt(st.nextToken());
		int M = parseInt(st.nextToken());
		boolean[] foods = new boolean[M];

		for(int i=0;i<N;i++) {
			st = new StringTokenizer(br.readLine());
			int K = parseInt(st.nextToken());

			List<Integer> indexList= new ArrayList<>();

			for(int j=0;j<K;j++) {
				int n = parseInt(st.nextToken());
				if(i==0) {
					foods[n-1] = true;
				}
				indexList.add(n);
			}

			for(int x=0;x<foods.length;x++) {
				if(foods[x] == true) {
					if(indexList.indexOf(x+1) == -1) {
						foods[x] = false;
					}
				}
			}

		}

		int sum = 0;
		for(int x=0;x<foods.length;x++) {
			if(foods[x] == true) {
				sum ++;
			}
		}

		System.out.println(sum);

	}
} public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st;
		st = new StringTokenizer(br.readLine());
		int N = parseInt(st.nextToken());
		int M = parseInt(st.nextToken());
		boolean[] foods = new boolean[M];

		for(int i=0;i<N;i++) {
			st = new StringTokenizer(br.readLine());
			int K = parseInt(st.nextToken());

			List<Integer> indexList= new ArrayList<>();

			for(int j=0;j<K;j++) {
				int n = parseInt(st.nextToken());
				if(i==0) {
					foods[n-1] = true;
				}
				indexList.add(n);
			}

			for(int x=0;x<foods.length;x++) {
				if(foods[x] == true) {
					if(indexList.indexOf(x+1) == -1) {
						foods[x] = false;
					}
				}
			}

		}

		int sum = 0;
		for(int x=0;x<foods.length;x++) {
			if(foods[x] == true) {
				sum ++;
			}
		}

		System.out.println(sum);

	}
} Main
import static java.lang.Integer.*;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st;
		st = new StringTokenizer(br.readLine());
		int N = parseInt(st.nextToken());
		int M = parseInt(st.nextToken());
		boolean[] foods = new boolean[M];

		for(int i=0;i<N;i++) {
			st = new StringTokenizer(br.readLine());
			int K = parseInt(st.nextToken());

			List<Integer> indexList= new ArrayList<>();

			for(int j=0;j<K;j++) {
				int n = parseInt(st.nextToken());
				if(i==0) {
					foods[n-1] = true;
				}
				indexList.add(n);
			}

			for(int x=0;x<foods.length;x++) {
				if(foods[x] == true) {
					if(indexList.indexOf(x+1) == -1) {
						foods[x] = false;
					}
				}
			}

		}

		int sum = 0;
		for(int x=0;x<foods.length;x++) {
			if(foods[x] == true) {
				sum ++;
			}
		}

		System.out.println(sum);

	}
}
