
import java.io.*;
import java.util.StringTokenizer;

/**
 * Created by sbabkin on 9/14/2015.
 */
public class SolverC {

    public static void main(String[] args) throws IOException {
        new SolverC().Run();
    }

    BufferedReader br;
    PrintWriter pw;
    StringTokenizer stok;

    private String nextToken() throws IOException {
        while (stok==null || !stok.hasMoreTokens()){
            stok = new StringTokenizer(br.readLine());
        }
        return stok.nextToken();
    }

    private int nextInt() throws IOException {
        return Integer.parseInt(nextToken());
    }

    private long nextLong() throws IOException {
        return Long.parseLong(nextToken());
    }

    private void Run() throws IOException {
//        br=new BufferedReader(new FileReader("input.txt"));
//        pw=new PrintWriter("output.txt");
        br=new BufferedReader(new InputStreamReader(System.in));
        pw=new PrintWriter(new OutputStreamWriter(System.out));

        int n=nextInt();
        int k=nextInt();
        int result=0;
        int off=0;
        for (int i=0; i<k;i++){
            int len=nextInt();
            int[] mas=new int[len];
            for (int j=0; j<len; j++){
                mas[j]=nextInt();
            }
            int j=1;
            if (mas[0]==1) {
                for (; j < len && mas[j - 1] + 1 == mas[j]; j++) {
                    off--;
                }
            }
            if (j<len) {
                result+=len-j;
            }
        }
        result=result+(n-1)+off;
        pw.println(result);
        pw.flush();
        pw.close();
    }

}
