import java.util.Scanner;

public class Main {

	public void solve() {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
		int works = N - 1;
		for (int k = 0; k < K; k++) {
			int Q = sc.nextInt();
			works += Q - 1;
			int[] a = new int[Q];
			for (int q = 0; q < Q; q++) {
				a[q] = sc.nextInt();
			}
			if (a[0] == 1) {
				for (int i = 1; i < Q; i++) {
					if (a[i] == i + 1) {
						works -= 2;
					} else {
						break;
					}
				}
			}
		}
		System.out.println(works);

	}

	public static void main(String[] args) {
		new Main().solve();
	}

}