import java.util.Scanner;


public class C {

	public static void main(String[] args) {
		
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int k = in.nextInt();
		
		int parts = 0;
		int disconnect = 0;
		for(int i=0;i<k;++i){
			int ki = in.nextInt();
			int seq[] = new int[ki];
			boolean firstPart = false;
			for(int j=0;j<ki;++j){
				seq[j] = in.nextInt();
				if(j==0&&seq[j]==1){
					firstPart = true;
					parts++;
					continue;
				}
				if(firstPart){
					if(seq[j]!=seq[j-1]+1){
						parts++;						
						disconnect++;
						firstPart = false;
					}
				}else{					
					parts++;
					if(j!=0){
						disconnect++;
					}
				}
			}
		}		
//		System.out.println(disconnect + " " + (parts-1));
		System.out.println(disconnect + (parts-1));
	}

}
