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(" ");
			int prev = -1;
			int curr = Integer.valueOf(saa[1]);
			for (int i = 1; i < saa.length; i++) {

				if (curr == 1) {
					int cur = curr;
					if (i == 1)
						prev = cur;
					else {
						if (prev == cur - 1) {
							prev = cur;
						} else {
					//		System.out.println(saa.length-i);
							totalpieces += (saa.length - i+1);
							op += (saa.length - i);
							break;
						}
					}
				} else {
				//	System.out.println("00" + saa.length);
					totalpieces += (saa.length - 1);
					op += (saa.length - 2);
					break;
				}
			}
			p++;
		}
	//	System.out.println(totalpieces);
		System.out.println(totalpieces - 1 + op);

	}

}
