import java.util.Scanner;

public class Main {

	static Scanner sc = new Scanner(System.in);
	static int n, k, m;
	static int counter = 0;
	static int minus = 0;
	
	public static void main(String[] args) {
		n = sc.nextInt();
		k = sc.nextInt();
		
		for (int i = 0; i != k; i++) {
			m = sc.nextInt();
			
			boolean b = false;
			for (int j = 0; j != m; j++) {
				int a = sc.nextInt();
				if (b) continue;
				
				if (j == 0 && a != 1) {counter += (m - 1); b = true; continue;}
				if (j == 0 && a == 1) {minus++; continue;}
				
				if (a - 1 == j) {minus++; continue;}
				
				counter += (m - j);
				b = true;
			}
		}
		
		System.out.println((counter + (n - minus)));
	}
}
