import java.util.*;
public class Solution{
   public static void main(String args[]){
	   Scanner s=new Scanner(System.in);
	   int n=s.nextInt();
	   int k=s.nextInt();
	   int ans=0;
	   int count=0;
	   for(int x=0;x<k;x++){
		   int p=s.nextInt();
		   int[] array=new int[p];
		   for(int q=0;q<p;q++){
			array[q]=s.nextInt();   
		   }
		   if(array[0]==1){
			   int u=1;
			   count=1;
			   while(u<p && array[u]==array[u-1]+1){
				   count++;
				   u++;
			   }
			   ans+=p-count;
		   }
		   else{
			   ans+=p-1;
		   }
		}
	   ans+=n-count;
	   System.out.println(ans);
   }	    

}


