import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.*;
import java.util.*;

import static java.util.stream.Collectors.*;
import static java.util.Map.Entry.*;

public class Main {

	public static void main(String[] args) throws IOException {
		FastReader in = new FastReader(System.in);
		PrintWriter out = new PrintWriter(System.out);
		int n = in.nextInt();
		int m = in.nextInt();
		int[] hash = new int[m + 1];
		for (int i = 0; i < n; i++) {
			int x =in.nextInt();
			for (int j = 0; j < x; j++) {
				hash[in.nextInt()]++;

			}

		}
		int ans = 0;
		for (int i = 0; i < hash.length; i++) {
			if (hash[i] == n) {
				++ans;
			}
		}
		out.println(ans);
		out.flush();
		out.close();

	}

	static class FastReader {
		StringTokenizer st;
		BufferedReader br;

		public FastReader(InputStream s) {
			br = new BufferedReader(new InputStreamReader(s));
		}

		public FastReader(FileReader fileReader) {
			br = new BufferedReader(fileReader);
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public int[] nextIntArray(int n) throws IOException {
			int[] ret = new int[n];
			for (int i = 0; i < n; i++) {
				ret[i] = nextInt();
			}
			return ret;
		}

		public long[] nextIntLong(int n) throws IOException {
			long[] ret = new long[n];
			for (int i = 0; i < n; i++) {
				ret[i] = nextLong();
			}
			return ret;
		}

		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}

		public String nextLine() throws IOException {
			return br.readLine();
		}

		public boolean ready() throws IOException {
			return br.ready();
		}
	}

} import java.io.BufferedReader; BufferedReader java.io import java.io.FileReader; FileReader java.io import java.io.IOException; IOException java.io import java.io.InputStream; InputStream java.io import java.io.InputStreamReader; InputStreamReader java.io import java.io.PrintWriter; PrintWriter java.io import java.math.*; math.* java import java.util.*; util.* java import static java.util.stream.Collectors.*; import static java.util.stream.Collectors.*; import static java.util.stream.Collectors.*; import static java.util.Map.Entry.*; import static java.util.Map.Entry.*; import static java.util.Map.Entry.*; public class Main {

	public static void main(String[] args) throws IOException {
		FastReader in = new FastReader(System.in);
		PrintWriter out = new PrintWriter(System.out);
		int n = in.nextInt();
		int m = in.nextInt();
		int[] hash = new int[m + 1];
		for (int i = 0; i < n; i++) {
			int x =in.nextInt();
			for (int j = 0; j < x; j++) {
				hash[in.nextInt()]++;

			}

		}
		int ans = 0;
		for (int i = 0; i < hash.length; i++) {
			if (hash[i] == n) {
				++ans;
			}
		}
		out.println(ans);
		out.flush();
		out.close();

	}

	static class FastReader {
		StringTokenizer st;
		BufferedReader br;

		public FastReader(InputStream s) {
			br = new BufferedReader(new InputStreamReader(s));
		}

		public FastReader(FileReader fileReader) {
			br = new BufferedReader(fileReader);
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public int[] nextIntArray(int n) throws IOException {
			int[] ret = new int[n];
			for (int i = 0; i < n; i++) {
				ret[i] = nextInt();
			}
			return ret;
		}

		public long[] nextIntLong(int n) throws IOException {
			long[] ret = new long[n];
			for (int i = 0; i < n; i++) {
				ret[i] = nextLong();
			}
			return ret;
		}

		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}

		public String nextLine() throws IOException {
			return br.readLine();
		}

		public boolean ready() throws IOException {
			return br.ready();
		}
	}

} Main public static void main(String[] args) throws IOException {
		FastReader in = new FastReader(System.in);
		PrintWriter out = new PrintWriter(System.out);
		int n = in.nextInt();
		int m = in.nextInt();
		int[] hash = new int[m + 1];
		for (int i = 0; i < n; i++) {
			int x =in.nextInt();
			for (int j = 0; j < x; j++) {
				hash[in.nextInt()]++;

			}

		}
		int ans = 0;
		for (int i = 0; i < hash.length; i++) {
			if (hash[i] == n) {
				++ans;
			}
		}
		out.println(ans);
		out.flush();
		out.close();

	} main {
		FastReader in = new FastReader(System.in);
		PrintWriter out = new PrintWriter(System.out);
		int n = in.nextInt();
		int m = in.nextInt();
		int[] hash = new int[m + 1];
		for (int i = 0; i < n; i++) {
			int x =in.nextInt();
			for (int j = 0; j < x; j++) {
				hash[in.nextInt()]++;

			}

		}
		int ans = 0;
		for (int i = 0; i < hash.length; i++) {
			if (hash[i] == n) {
				++ans;
			}
		}
		out.println(ans);
		out.flush();
		out.close();

	} FastReader in = new FastReader(System.in); in new FastReader(System.in) PrintWriter out = new PrintWriter(System.out); out new PrintWriter(System.out) int n = in.nextInt(); n in.nextInt() in.nextInt in int m = in.nextInt(); m in.nextInt() in.nextInt in int[] hash = new int[m + 1]; hash new int[m + 1] m + 1 m 1 for (int i = 0; i < n; i++) {
			int x =in.nextInt();
			for (int j = 0; j < x; j++) {
				hash[in.nextInt()]++;

			}

		} int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
			int x =in.nextInt();
			for (int j = 0; j < x; j++) {
				hash[in.nextInt()]++;

			}

		} {
			int x =in.nextInt();
			for (int j = 0; j < x; j++) {
				hash[in.nextInt()]++;

			}

		} int x =in.nextInt(); x in.nextInt() in.nextInt in for (int j = 0; j < x; j++) {
				hash[in.nextInt()]++;

			} int j = 0; int j = 0; j 0 j < x j x j++ j++ j {
				hash[in.nextInt()]++;

			} {
				hash[in.nextInt()]++;

			} hash[in.nextInt()]++ hash[in.nextInt()] hash in.nextInt() in.nextInt in int ans = 0; ans 0 for (int i = 0; i < hash.length; i++) {
			if (hash[i] == n) {
				++ans;
			}
		} int i = 0; int i = 0; i 0 i < hash.length i hash.length hash hash.length i++ i++ i {
			if (hash[i] == n) {
				++ans;
			}
		} {
			if (hash[i] == n) {
				++ans;
			}
		} if (hash[i] == n) {
				++ans;
			} hash[i] == n hash[i] hash i n {
				++ans;
			} ++ans ans out.println(ans) out.println out ans out.flush() out.flush out out.close() out.close out String[] args args static class FastReader {
		StringTokenizer st;
		BufferedReader br;

		public FastReader(InputStream s) {
			br = new BufferedReader(new InputStreamReader(s));
		}

		public FastReader(FileReader fileReader) {
			br = new BufferedReader(fileReader);
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public int[] nextIntArray(int n) throws IOException {
			int[] ret = new int[n];
			for (int i = 0; i < n; i++) {
				ret[i] = nextInt();
			}
			return ret;
		}

		public long[] nextIntLong(int n) throws IOException {
			long[] ret = new long[n];
			for (int i = 0; i < n; i++) {
				ret[i] = nextLong();
			}
			return ret;
		}

		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}

		public String nextLine() throws IOException {
			return br.readLine();
		}

		public boolean ready() throws IOException {
			return br.ready();
		}
	} FastReader StringTokenizer st; st BufferedReader br; br public FastReader(InputStream s) {
			br = new BufferedReader(new InputStreamReader(s));
		} FastReader {
			br = new BufferedReader(new InputStreamReader(s));
		} br = new BufferedReader(new InputStreamReader(s)) br new BufferedReader(new InputStreamReader(s)) InputStream s s public FastReader(FileReader fileReader) {
			br = new BufferedReader(fileReader);
		} FastReader {
			br = new BufferedReader(fileReader);
		} br = new BufferedReader(fileReader) br new BufferedReader(fileReader) FileReader fileReader fileReader public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		} next {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		} while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine()); st == null || !st.hasMoreTokens() st == null st null !st.hasMoreTokens() st.hasMoreTokens() st.hasMoreTokens st st = new StringTokenizer(br.readLine()) st new StringTokenizer(br.readLine()) return st.nextToken(); st.nextToken() st.nextToken st public int nextInt() throws IOException {
			return Integer.parseInt(next());
		} nextInt {
			return Integer.parseInt(next());
		} return Integer.parseInt(next()); Integer.parseInt(next()) Integer.parseInt Integer next() next public int[] nextIntArray(int n) throws IOException {
			int[] ret = new int[n];
			for (int i = 0; i < n; i++) {
				ret[i] = nextInt();
			}
			return ret;
		} nextIntArray {
			int[] ret = new int[n];
			for (int i = 0; i < n; i++) {
				ret[i] = nextInt();
			}
			return ret;
		} int[] ret = new int[n]; ret new int[n] n for (int i = 0; i < n; i++) {
				ret[i] = nextInt();
			} int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
				ret[i] = nextInt();
			} {
				ret[i] = nextInt();
			} ret[i] = nextInt() ret[i] ret i nextInt() nextInt return ret; ret int n n public long[] nextIntLong(int n) throws IOException {
			long[] ret = new long[n];
			for (int i = 0; i < n; i++) {
				ret[i] = nextLong();
			}
			return ret;
		} nextIntLong {
			long[] ret = new long[n];
			for (int i = 0; i < n; i++) {
				ret[i] = nextLong();
			}
			return ret;
		} long[] ret = new long[n]; ret new long[n] n for (int i = 0; i < n; i++) {
				ret[i] = nextLong();
			} int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
				ret[i] = nextLong();
			} {
				ret[i] = nextLong();
			} ret[i] = nextLong() ret[i] ret i nextLong() nextLong return ret; ret int n n public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		} nextDouble {
			return Double.parseDouble(next());
		} return Double.parseDouble(next()); Double.parseDouble(next()) Double.parseDouble Double next() next public long nextLong() throws IOException {
			return Long.parseLong(next());
		} nextLong {
			return Long.parseLong(next());
		} return Long.parseLong(next()); Long.parseLong(next()) Long.parseLong Long next() next public String nextLine() throws IOException {
			return br.readLine();
		} nextLine {
			return br.readLine();
		} return br.readLine(); br.readLine() br.readLine br public boolean ready() throws IOException {
			return br.ready();
		} ready {
			return br.ready();
		} return br.ready(); br.ready() br.ready br public class Main {

	public static void main(String[] args) throws IOException {
		FastReader in = new FastReader(System.in);
		PrintWriter out = new PrintWriter(System.out);
		int n = in.nextInt();
		int m = in.nextInt();
		int[] hash = new int[m + 1];
		for (int i = 0; i < n; i++) {
			int x =in.nextInt();
			for (int j = 0; j < x; j++) {
				hash[in.nextInt()]++;

			}

		}
		int ans = 0;
		for (int i = 0; i < hash.length; i++) {
			if (hash[i] == n) {
				++ans;
			}
		}
		out.println(ans);
		out.flush();
		out.close();

	}

	static class FastReader {
		StringTokenizer st;
		BufferedReader br;

		public FastReader(InputStream s) {
			br = new BufferedReader(new InputStreamReader(s));
		}

		public FastReader(FileReader fileReader) {
			br = new BufferedReader(fileReader);
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public int[] nextIntArray(int n) throws IOException {
			int[] ret = new int[n];
			for (int i = 0; i < n; i++) {
				ret[i] = nextInt();
			}
			return ret;
		}

		public long[] nextIntLong(int n) throws IOException {
			long[] ret = new long[n];
			for (int i = 0; i < n; i++) {
				ret[i] = nextLong();
			}
			return ret;
		}

		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}

		public String nextLine() throws IOException {
			return br.readLine();
		}

		public boolean ready() throws IOException {
			return br.ready();
		}
	}

} public class Main {

	public static void main(String[] args) throws IOException {
		FastReader in = new FastReader(System.in);
		PrintWriter out = new PrintWriter(System.out);
		int n = in.nextInt();
		int m = in.nextInt();
		int[] hash = new int[m + 1];
		for (int i = 0; i < n; i++) {
			int x =in.nextInt();
			for (int j = 0; j < x; j++) {
				hash[in.nextInt()]++;

			}

		}
		int ans = 0;
		for (int i = 0; i < hash.length; i++) {
			if (hash[i] == n) {
				++ans;
			}
		}
		out.println(ans);
		out.flush();
		out.close();

	}

	static class FastReader {
		StringTokenizer st;
		BufferedReader br;

		public FastReader(InputStream s) {
			br = new BufferedReader(new InputStreamReader(s));
		}

		public FastReader(FileReader fileReader) {
			br = new BufferedReader(fileReader);
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public int[] nextIntArray(int n) throws IOException {
			int[] ret = new int[n];
			for (int i = 0; i < n; i++) {
				ret[i] = nextInt();
			}
			return ret;
		}

		public long[] nextIntLong(int n) throws IOException {
			long[] ret = new long[n];
			for (int i = 0; i < n; i++) {
				ret[i] = nextLong();
			}
			return ret;
		}

		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}

		public String nextLine() throws IOException {
			return br.readLine();
		}

		public boolean ready() throws IOException {
			return br.ready();
		}
	}

} Main
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.*;
import java.util.*;

import static java.util.stream.Collectors.*;
import static java.util.Map.Entry.*;

public class Main {

	public static void main(String[] args) throws IOException {
		FastReader in = new FastReader(System.in);
		PrintWriter out = new PrintWriter(System.out);
		int n = in.nextInt();
		int m = in.nextInt();
		int[] hash = new int[m + 1];
		for (int i = 0; i < n; i++) {
			int x =in.nextInt();
			for (int j = 0; j < x; j++) {
				hash[in.nextInt()]++;

			}

		}
		int ans = 0;
		for (int i = 0; i < hash.length; i++) {
			if (hash[i] == n) {
				++ans;
			}
		}
		out.println(ans);
		out.flush();
		out.close();

	}

	static class FastReader {
		StringTokenizer st;
		BufferedReader br;

		public FastReader(InputStream s) {
			br = new BufferedReader(new InputStreamReader(s));
		}

		public FastReader(FileReader fileReader) {
			br = new BufferedReader(fileReader);
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public int[] nextIntArray(int n) throws IOException {
			int[] ret = new int[n];
			for (int i = 0; i < n; i++) {
				ret[i] = nextInt();
			}
			return ret;
		}

		public long[] nextIntLong(int n) throws IOException {
			long[] ret = new long[n];
			for (int i = 0; i < n; i++) {
				ret[i] = nextLong();
			}
			return ret;
		}

		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}

		public String nextLine() throws IOException {
			return br.readLine();
		}

		public boolean ready() throws IOException {
			return br.ready();
		}
	}

}