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

public class A556 {

	public static void main(String[] args) throws IOException {
		initReader();
		int n = nextInt();
		int k = nextInt();
		int inChain[] = new int[n + 1];
		int[][] chains = new int[k][];
		int index[] = new int[k];
		int count = 0;
		for (int i = 0; i < k; ++i) {
			int t = nextInt();
			chains[i] = new int[t];
			for (int j = 0; j < t; ++j) {
				int b = nextInt();
				chains[i][j] = b;
				inChain[b] = i;
				if (j == 0 || chains[i][j] != chains[i][j - 1] + 1) {
					count++;
				}
			}
		}
		System.out.println(count - 1);

	}

	static BufferedReader reader;
	static StringTokenizer tokenizer;

	public static void initReader() {
		reader = new BufferedReader(new InputStreamReader(System.in));
		tokenizer = new StringTokenizer("");
	}

	static String next() throws IOException {
		while (!tokenizer.hasMoreTokens()) {
			tokenizer = new StringTokenizer(reader.readLine());
		}
		return tokenizer.nextToken();
	}

	static String nextLine() throws IOException {
		return reader.readLine();
	}

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

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

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