import java.io.*;
import java.util.*;

public class CF556C {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer(br.readLine());
		int n = Integer.parseInt(st.nextToken());
		int k = Integer.parseInt(st.nextToken());
		int s = (n - k) + (n - 1);
		while (k-- > 0) {
			st = new StringTokenizer(br.readLine());
			int m = Integer.parseInt(st.nextToken());
			for (int i = 1; i <= m; i++) {
				int a = Integer.parseInt(st.nextToken());
				if (a != i)
					break;
				if (a > 1)
					s -= 2;
			}
		}
		System.out.println(s);
	}
}
