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

public class P3 {
	public static void main (String[] args) {
		Scanner sc = new Scanner (System.in);
		PrintStream op = System.out;
		int n = sc.nextInt(), k = sc.nextInt();
		int[] m = new int [k];
		int ans = 0;
		for (int i = 0 ; i < k; i++) {
			m[i] = sc.nextInt();
			int[] t = new int [m[i]];
			int l = m[i];
			for (int j = 0; j < m[i]; j++)
				t[j] = sc.nextInt();
			for (int j = m[i] - 2; j >= 0; j--) {
				if (t[j + 1] == (t[j] + 1))
					l--;
				else
					break;
			}
			ans += l;
		}
		op.println(2 * ans - 1 - k);
		sc.close();
		op.close();
	}
}
