import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintStream;
import java.util.StringTokenizer;

public class CaseOfMatryoshkas_555A {
public static void main(String args[]) throws IOException{
	BufferedReader sIn=new BufferedReader(new InputStreamReader(System.in));
	PrintStream sOut =new PrintStream(System.out);
	
	StringTokenizer st=new StringTokenizer(sIn.readLine());
	int n=Integer.parseInt(st.nextToken());
	int m=Integer.parseInt(st.nextToken());
	int tot[]=new int[m];
	int num[];
	int count=0,total=0;
	for(int i=0;i<m;i++){
		st=new StringTokenizer(sIn.readLine());
		tot[i]=Integer.parseInt(st.nextToken());
		 num=new int[tot[i]];
		 num[0]=Integer.parseInt(st.nextToken());
		 if(num[0]==1){
			 for(int j=1;j<tot[i];j++){
				 num[j]=Integer.parseInt(st.nextToken());
				// sOut.print(num[j]+" ");
				 if((num[j]-num[j-1])==1)
					 count++;
				 else
					 break;
			 }
		 }
		 total+=(tot[i]-1);
	}
	//sOut.println(count);
	sOut.println(n-(count+1)+total-count);
	
	sOut.close();
}
}