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

public class Main {
    
    public static void main(String[] args)throws IOException {
        Reader.init(System.in);
        StringBuffer s=new StringBuffer();
        int num=Reader.nextInt(),l=Reader.nextInt(),t=0,r=0,n[];
        while(--l>=0) {
            n=new int[Reader.nextInt()];
            n[0]=Reader.nextInt();
            for(int i=1;i<n.length;i++) {
                n[i]=Reader.nextInt();
                if(n[i]-n[i-1]==1) t++;
                else r++;
            }
        }
        s.append((r+num-1-t)+"\n");
        System.out.print(s);
    }
}

class Reader {
    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 String nextLine() throws IOException {
        return reader.readLine();
    }

    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() );
    }
}