import java.util.*;

public class matosky {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.nextLine();
		String[] sa = s.split(" ");
		int n = Integer.valueOf(sa[0]);
		int k = Integer.valueOf(sa[1]);
		int p = 0;
		int totalpieces = 0;
		int op = 0;
		while (k > p) {
			String ss = sc.nextLine();
			String[] saa = ss.split(" ");
			totalpieces++;
			int prev = -1;
			for (int i = 1; i < saa.length; i++) {
				if (i == 1)
					prev = Integer.valueOf(saa[i]);
				else {
					int cur = Integer.valueOf(saa[i]);
					if (cur - 1 != prev) {
						prev = cur;
						totalpieces++;
						op++;
					}
					else
					{
						prev = cur;
					}
				}
			}
			p++;
		}
		System.out.println(totalpieces - 1 + op);

	}

}
