//package july07;

import java.util.Scanner;

public class TaskC {
	private int n, k;
	
	private int answer;
	
	public void inputdata() {
		Scanner scanner = new Scanner(System.in);
		
		int n = scanner.nextInt();
		int k = scanner.nextInt();
		
		answer = k - 1;
		
		for (int i = 0; i < k; i++) {
			int m = scanner.nextInt();
			
			boolean goodChain = true;
			for (int j = 0; j < m; j++) {
				int cur = scanner.nextInt();
				goodChain &= (cur == j + 1);
				
				if (j > 0 && !goodChain) {
					answer += 2;
				}
			}
		}
	}
	
	public void outputdata() {
		System.out.println(answer);
	}
	
	public static void main(String[] args) {
		TaskC task = new TaskC();
		task.inputdata();
		task.outputdata();
	}

}
