import java.util.Scanner;
import java.util.*;
public class R310C{
	public static void main(String[] args){
		Scanner in = new Scanner(System.in);
		int dolls = in.nextInt();
		int lineCount = in.nextInt();

		ArrayList<ArrayList<Integer>> lines = new ArrayList<ArrayList<Integer>>();
		for(int i = 0; i < lineCount; i++){
			int lineLength = in.nextInt();
			ArrayList<Integer> oneLine = new ArrayList<Integer>();
			for(int j = 0; j < lineLength; j++){
				int nextDoll = in.nextInt();
				oneLine.add(j, nextDoll);
			}
			lines.add(i, oneLine);
		}
		int count = lineCount-1;
		int decomposedLines = lineCount;

		for(int i = 0; i < lineCount; i++){
			ArrayList<Integer> currentL = lines.get(i);
			int previous = -1;
			for(int j=0; j < currentL.size(); j++){
				int currentElement = currentL.get(j);
				if(currentElement - 1 != previous && previous != -1){
					count = count + 2;
				}
				previous = currentElement;
			}
			previous = -1;
		}
		System.out.println(count);
	}
}