import java.util.*; 
import java.math.*;
import java.io.*;
public class Main{static int  m;
static BigInteger w;
static String h;
    public static void main(String[] args)  throws IOException {
        input.init(System.in);
        PrintWriter out = new PrintWriter(System.out);
		int n=input.nextInt();
		int k=input.nextInt();
		int[] a=new int[k];
		int[][] b=new int[k][];
		long ct=0;
		int[] z=new int[n];
		int l=0;
		for(int i=0;i<k;i++){
			a[i]=input.nextInt();
			b[i]=new int[a[i]];
			
			for(int j=0;j<a[i];j++){
				b[i][j]=input.nextInt();
				z[l+j]=b[i][j];
				
			}
			l+=a[i];
		}
		Arrays.sort(z);
		for(int i=0;i<k;i++){
			
			for(int j=0;j<a[i];j++){
				
				if(j>0&&z[Arrays.binarySearch(z,b[i][j-1])+1]!=b[i][j])
					ct+=2;
				if(j==a[i]-1&&b[i][j]!=z[n-1])
					ct++;
			}
			l+=a[i];
		}
		System.out.println(ct);
	}
		
		
	
    public static class input {
    static BufferedReader reader;
    static StringTokenizer tokenizer;
 
    /** call this method to initialize reader for InputStream */
    static void init(InputStream input) {
        reader = new BufferedReader(
                     new InputStreamReader(input) );
        tokenizer = new StringTokenizer("");
    }
 
    /** get next word */
    static String next() throws IOException {
        while ( ! tokenizer.hasMoreTokens() ) {
            //TODO add check for eof if necessary
            tokenizer = new StringTokenizer(
                   reader.readLine() );
        }
        return tokenizer.nextToken();
    }
 
    static int nextInt() throws IOException {
        return Integer.parseInt( next() );
    }
    
    static double nextDouble() throws IOException {
        return Double.parseDouble( next() );
    }
    static long nextLong() throws IOException {
        return Long.parseLong( next() );
    }
}
}    
 
