import java.util.*;

public class problemC {
	
	static Scanner sc = new Scanner(System.in);
	
	public static void main(String[] args) {
		
		int n = sc.nextInt();
		int c = sc.nextInt();
		int time = 0;
		
		for (int i = 0; i < c; i++) {
			int z = sc.nextInt();
			int[] chain = new int[z];
			chain[0] = sc.nextInt();
			boolean chained = true;
			for (int j = 1; j < z; j++) {
				chain[1] = sc.nextInt();
				if (chain[j] - chain[j-1] != 1 && chained) {
					time += 2 * (z-j) + 1;
					chained = false;
				
				
				}
			}
			
			if (chained) {
				time++;
			}
		}
		
		System.out.println(time-1);
		
	}

}
