import java.io.*;
import java.util.*;
import java.math.*;

public class Main{
    public static void main(String[] args)throws Throwable{
        Escanner sc = new Escanner();
        out = new PrintWriter(System.out);
        //////////
        int n = sc.nextInt();
        int k = sc.nextInt();
        int[] g = new int[n+1];
        for(int i=0; i<k; i++){
            int m = sc.nextInt();
            int a = sc.nextInt();
            for(int j=0; j<m-1; j++){
                int b = sc.nextInt();
                g[a] = b;
                a = b;
            }
        }

        int cnt = 0;
        for(int mat=1; mat<n; mat++){
            if(g[mat]==mat+1)
                continue;
            if(g[mat]!=0)
                cnt++;
            if(g[mat+1]!=0){
                g[mat+1]  =0;
                cnt++;
            }
            cnt++;
        }
        out.println(cnt);
        //////////
        out.close();
    }
    static class Escanner {
        BufferedReader in;
        StringTokenizer st;

        Escanner() throws Throwable {
            in = new BufferedReader(new InputStreamReader(System.in),32768);
            st = new StringTokenizer("");
        }
        Escanner(String fileName) throws Throwable {
            in = new BufferedReader(new FileReader(fileName),32768);
            st = new StringTokenizer("");
        }

        String nextStr() throws Throwable {
            while(!st.hasMoreTokens())
                st = new StringTokenizer(in.readLine());
            return st.nextToken();
        }

        int nextInt() throws Throwable {
            return Integer.parseInt(nextStr());
        }

        long nextLong() throws Throwable {
            return Long.parseLong(nextStr());
        }

        BigInteger nextBigInt() throws Throwable {
            return new BigInteger(nextStr());
        }

        double nextDouble() throws Throwable {
            return Double.parseDouble(nextStr());
        }
    }
    static PrintWriter out;
}