import java.util.*;

public class C {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int m = in.nextInt();
		ArrayList<ArrayList<Integer>> list = new ArrayList<>();
		for (int i = 0; i < m; i++) {
			ArrayList<Integer> temp = new ArrayList<>();
			int inLine = in.nextInt();
			for (int j = 0; j < inLine; j++) {
				temp.add(in.nextInt());
			}
			list.add(temp);
		}
		int count = 0;
		int numstuff = 0;
		
		for (int i = 0; i < list.size(); i++) {
			int k = 2;
			int temp = 1;
			for (int j = 1; j < list.get(i).size(); j++) {
				if (list.get(i).get(j) != list.get(i).get(j-1)+1) {
					temp++;
					count++;
				} else if (list.get(i).get(j) == k) {
					k++;
				} else {
					temp++;
					count++;
				}
			}
			numstuff+=temp;
		}
		count+=numstuff-1;
		System.out.println(count);
	}

}
