
import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Scanner;
import java.util.Set;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int k = scan.nextInt();

		String array[][] = new String[n][k];

		for (int i = 0; i < k; i++) {
			int d = scan.nextInt();
			for (int h = 0; h < d; h++) {
				int j = scan.nextInt();
				array[j - 1][i] = "aaa";
			}
		}


		String[] list = {null};
		int ans =0;
		for (int b = 0; b < n; b++) {
			String[] a = array[b];

			List asList = Arrays.asList(list);
			List asList1 = Arrays.asList(a);
			Set<String> mySet = new HashSet<String>(asList);
			for (String s : mySet) {
//				System.out.println(s + " " + Collections.frequency(asList1, s));
				if(k== Collections.frequency(asList1, s)) {
					ans += 1;

				}
			}
		}


		System.out.println(ans);
	}
} import java.util.Arrays; Arrays java.util import java.util.Collections; Collections java.util import java.util.HashSet; HashSet java.util import java.util.List; List java.util import java.util.Scanner; Scanner java.util import java.util.Set; Set java.util public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int k = scan.nextInt();

		String array[][] = new String[n][k];

		for (int i = 0; i < k; i++) {
			int d = scan.nextInt();
			for (int h = 0; h < d; h++) {
				int j = scan.nextInt();
				array[j - 1][i] = "aaa";
			}
		}


		String[] list = {null};
		int ans =0;
		for (int b = 0; b < n; b++) {
			String[] a = array[b];

			List asList = Arrays.asList(list);
			List asList1 = Arrays.asList(a);
			Set<String> mySet = new HashSet<String>(asList);
			for (String s : mySet) {
//				System.out.println(s + " " + Collections.frequency(asList1, s));
				if(k== Collections.frequency(asList1, s)) {
					ans += 1;

				}
			}
		}


		System.out.println(ans);
	}
} Main public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int k = scan.nextInt();

		String array[][] = new String[n][k];

		for (int i = 0; i < k; i++) {
			int d = scan.nextInt();
			for (int h = 0; h < d; h++) {
				int j = scan.nextInt();
				array[j - 1][i] = "aaa";
			}
		}


		String[] list = {null};
		int ans =0;
		for (int b = 0; b < n; b++) {
			String[] a = array[b];

			List asList = Arrays.asList(list);
			List asList1 = Arrays.asList(a);
			Set<String> mySet = new HashSet<String>(asList);
			for (String s : mySet) {
//				System.out.println(s + " " + Collections.frequency(asList1, s));
				if(k== Collections.frequency(asList1, s)) {
					ans += 1;

				}
			}
		}


		System.out.println(ans);
	} main {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int k = scan.nextInt();

		String array[][] = new String[n][k];

		for (int i = 0; i < k; i++) {
			int d = scan.nextInt();
			for (int h = 0; h < d; h++) {
				int j = scan.nextInt();
				array[j - 1][i] = "aaa";
			}
		}


		String[] list = {null};
		int ans =0;
		for (int b = 0; b < n; b++) {
			String[] a = array[b];

			List asList = Arrays.asList(list);
			List asList1 = Arrays.asList(a);
			Set<String> mySet = new HashSet<String>(asList);
			for (String s : mySet) {
//				System.out.println(s + " " + Collections.frequency(asList1, s));
				if(k== Collections.frequency(asList1, s)) {
					ans += 1;

				}
			}
		}


		System.out.println(ans);
	} Scanner scan = new Scanner(System.in); scan new Scanner(System.in) int n = scan.nextInt(); n scan.nextInt() scan.nextInt scan int k = scan.nextInt(); k scan.nextInt() scan.nextInt scan String array[][] = new String[n][k]; array new String[n][k] n k for (int i = 0; i < k; i++) {
			int d = scan.nextInt();
			for (int h = 0; h < d; h++) {
				int j = scan.nextInt();
				array[j - 1][i] = "aaa";
			}
		} int i = 0; int i = 0; i 0 i < k i k i++ i++ i {
			int d = scan.nextInt();
			for (int h = 0; h < d; h++) {
				int j = scan.nextInt();
				array[j - 1][i] = "aaa";
			}
		} {
			int d = scan.nextInt();
			for (int h = 0; h < d; h++) {
				int j = scan.nextInt();
				array[j - 1][i] = "aaa";
			}
		} int d = scan.nextInt(); d scan.nextInt() scan.nextInt scan for (int h = 0; h < d; h++) {
				int j = scan.nextInt();
				array[j - 1][i] = "aaa";
			} int h = 0; int h = 0; h 0 h < d h d h++ h++ h {
				int j = scan.nextInt();
				array[j - 1][i] = "aaa";
			} {
				int j = scan.nextInt();
				array[j - 1][i] = "aaa";
			} int j = scan.nextInt(); j scan.nextInt() scan.nextInt scan array[j - 1][i] = "aaa" array[j - 1][i] array[j - 1] array j - 1 j 1 i "aaa" String[] list = {null}; list {null} null int ans =0; ans 0 for (int b = 0; b < n; b++) {
			String[] a = array[b];

			List asList = Arrays.asList(list);
			List asList1 = Arrays.asList(a);
			Set<String> mySet = new HashSet<String>(asList);
			for (String s : mySet) {
//				System.out.println(s + " " + Collections.frequency(asList1, s));
				if(k== Collections.frequency(asList1, s)) {
					ans += 1;

				}
			}
		} int b = 0; int b = 0; b 0 b < n b n b++ b++ b {
			String[] a = array[b];

			List asList = Arrays.asList(list);
			List asList1 = Arrays.asList(a);
			Set<String> mySet = new HashSet<String>(asList);
			for (String s : mySet) {
//				System.out.println(s + " " + Collections.frequency(asList1, s));
				if(k== Collections.frequency(asList1, s)) {
					ans += 1;

				}
			}
		} {
			String[] a = array[b];

			List asList = Arrays.asList(list);
			List asList1 = Arrays.asList(a);
			Set<String> mySet = new HashSet<String>(asList);
			for (String s : mySet) {
//				System.out.println(s + " " + Collections.frequency(asList1, s));
				if(k== Collections.frequency(asList1, s)) {
					ans += 1;

				}
			}
		} String[] a = array[b]; a array[b] array b List asList = Arrays.asList(list); asList Arrays.asList(list) Arrays.asList Arrays list List asList1 = Arrays.asList(a); asList1 Arrays.asList(a) Arrays.asList Arrays a Set<String> mySet = new HashSet<String>(asList); mySet new HashSet<String>(asList) for (String s : mySet) {
//				System.out.println(s + " " + Collections.frequency(asList1, s));
				if(k== Collections.frequency(asList1, s)) {
					ans += 1;

				}
			} String s mySet {
//				System.out.println(s + " " + Collections.frequency(asList1, s));
				if(k== Collections.frequency(asList1, s)) {
					ans += 1;

				}
			} {
//				System.out.println(s + " " + Collections.frequency(asList1, s));
				if(k== Collections.frequency(asList1, s)) {
					ans += 1;

				}
			} if(k== Collections.frequency(asList1, s)) {
					ans += 1;

				} k== Collections.frequency(asList1, s) k Collections.frequency(asList1, s) Collections.frequency Collections asList1 s {
					ans += 1;

				} ans += 1 ans 1 System.out.println(ans) System.out.println System.out System System.out ans String[] args args public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int k = scan.nextInt();

		String array[][] = new String[n][k];

		for (int i = 0; i < k; i++) {
			int d = scan.nextInt();
			for (int h = 0; h < d; h++) {
				int j = scan.nextInt();
				array[j - 1][i] = "aaa";
			}
		}


		String[] list = {null};
		int ans =0;
		for (int b = 0; b < n; b++) {
			String[] a = array[b];

			List asList = Arrays.asList(list);
			List asList1 = Arrays.asList(a);
			Set<String> mySet = new HashSet<String>(asList);
			for (String s : mySet) {
//				System.out.println(s + " " + Collections.frequency(asList1, s));
				if(k== Collections.frequency(asList1, s)) {
					ans += 1;

				}
			}
		}


		System.out.println(ans);
	}
} public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int k = scan.nextInt();

		String array[][] = new String[n][k];

		for (int i = 0; i < k; i++) {
			int d = scan.nextInt();
			for (int h = 0; h < d; h++) {
				int j = scan.nextInt();
				array[j - 1][i] = "aaa";
			}
		}


		String[] list = {null};
		int ans =0;
		for (int b = 0; b < n; b++) {
			String[] a = array[b];

			List asList = Arrays.asList(list);
			List asList1 = Arrays.asList(a);
			Set<String> mySet = new HashSet<String>(asList);
			for (String s : mySet) {
//				System.out.println(s + " " + Collections.frequency(asList1, s));
				if(k== Collections.frequency(asList1, s)) {
					ans += 1;

				}
			}
		}


		System.out.println(ans);
	}
} Main

import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Scanner;
import java.util.Set;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int k = scan.nextInt();

		String array[][] = new String[n][k];

		for (int i = 0; i < k; i++) {
			int d = scan.nextInt();
			for (int h = 0; h < d; h++) {
				int j = scan.nextInt();
				array[j - 1][i] = "aaa";
			}
		}


		String[] list = {null};
		int ans =0;
		for (int b = 0; b < n; b++) {
			String[] a = array[b];

			List asList = Arrays.asList(list);
			List asList1 = Arrays.asList(a);
			Set<String> mySet = new HashSet<String>(asList);
			for (String s : mySet) {
//				System.out.println(s + " " + Collections.frequency(asList1, s));
				if(k== Collections.frequency(asList1, s)) {
					ans += 1;

				}
			}
		}


		System.out.println(ans);
	}
}