
import java.io.*;
import java.util.InputMismatchException;

public class CaseOfMatryoshkas {

    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastScanner in = new FastScanner(inputStream);
        FastPrinter out = new FastPrinter(outputStream);
        TaskS solver = new TaskS();
        solver.solve(1, in, out);
        out.close();
    }


    private static class TaskS {


        public void solve(int testNumber, FastScanner in, FastPrinter out) {
            int n = in.nextInt() ;
            int k = in.nextInt();
            int[][] a = new int[k][];
//            int minVal = Integer.MAX_VALUE;
            int minInd = -1;

            for (int i=0; i<k; i++) {
                int m = in.nextInt();
                a[i] = new int[m] ;
                for(int j=0; j<m; j++){
                    a[i][j] = in.nextInt();
                    if(a[i][j]==1){
                        minInd = i;
                    }
                }
            }
            int t = 0;
            int st = 0;
            for (int j=0; j<a[minInd].length; j++) {
//                int diff = a[minInd][j+1] - a[minInd][j] ;
//                out.println("## " + a[minInd][j] + " " + a[minInd][j+1] );
//                        + ", diff = " + diff);

                if( j==a[minInd].length-1 ){
                    st = a[minInd][j];
                    break;
                }else if(a[minInd][j+1]-a[minInd][j]>1){
//                if(diff>1 &&){
//                    out.println("**** " + a[minInd][j] + " ");
                    st = a[minInd][j];
                    break;
                }
            }
//            out.println();
//            out.println("minInd = " + minInd);
//            out.println("st = " + st);

            int res = 2*(n-st)-(k-1);
            out.println(res);

//            for (int i=0; i<k; i++) {
//                for (int j=0; j<a[i].length; j++) {
//                    out.print(a[i][j] + " ");
//                }
//                out.println();
//            }


        }
    }


    private static class FastScanner extends BufferedReader {

        public FastScanner(InputStream is) {
            super(new InputStreamReader(is));
        }

        public int read() {
            try {
                return super.read();
            } catch (IOException e) {
                throw new InputMismatchException();
            }
        }

        static boolean isWhiteSpace(int c) {
            return c >= 0 && c <= 32;
        }

        public int nextInt() {
            int c = read();
            while (isWhiteSpace(c)) {
                c = read();
            }
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int ret = 0;
            while (c >= 0 && !isWhiteSpace(c)) {
                if (c < '0' || c > '9') {
                    throw new NumberFormatException("digit expected " + (char) c
                            + " found");
                }
                ret = ret * 10 + c - '0';
                c = read();
            }
            return ret * sgn;
        }

        public long nextLong() {
            int c = read();
            while (isWhiteSpace(c)) {
                c = read();
            }
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            long ret = 0;
            while (c >= 0 && !isWhiteSpace(c)) {
                if (c < '0' || c > '9') {
                    throw new NumberFormatException("digit expected " + (char) c
                            + " found");
                }
                ret = ret * 10 + c - '0';
                c = read();
            }
            return ret * sgn;
        }

        public String readLine() {
            try {
                return super.readLine();
            } catch (IOException e) {
                return null;
            }
        }

        public int[] readIntArray(int n) {
            int[] ret = new int[n];
            for (int i = 0; i < n; i++) {
                ret[i] = nextInt();
            }
            return ret;
        }
    }

    private static class FastPrinter extends PrintWriter {
        public FastPrinter(OutputStream out) {
            super(out);
        }
    }
}