import java.io.InputStreamReader;
import java.io.IOException;
import java.util.InputMismatchException;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.Reader;
import java.io.Writer;
import java.io.InputStream;
import java.nio.CharBuffer;
import java.util.*;
import java.text.*;

/**
 *
 * @author Arthur Gazizov
 */
public class Main {
    public static void main(String[] args) {
    InputStream inputStream = System.in;
    OutputStream outputStream = System.out;
    FastScanner in = new FastScanner(inputStream);
    FastPrinter out = new FastPrinter(outputStream);
    Task solver = new Task();
//  int testCount = Integer.parseInt(in.next());
//  for (int i = 1; i <= testCount; i++)
//            solver.solve(i, in, out);
        solver.solve(1, in, out);
    out.close();
    }
}

class Task {
    static int[][] a;
    static Doll[] doll;
    public void solve(int testNumber, FastScanner in, FastPrinter out) {
        int n = in.nextInt();
        int timer = 0;
        doll = new Doll[n];
        for (int i = 0; i < n; i++) {
            doll[i] = new Doll();
        }
        int k = in.nextInt();
        a = new int[k][];
        for (int i = 0; i < k; i++) {
            int m = in.nextInt();
            timer += m - 1;
            a[i] = new int[m];
            for (int j = 0; j < m; j++) {
                a[i][j] = in.nextInt() - 1;
                if (j > 0){
                    doll[a[i][j-1]].parent = a[i][j];
                }
            }
            doll[a[i][m-1]].free = true;
        }
        
        
//        for (int i = 0; i < k; i++) {
//            timer += a[k].length;
//        }
        timer += n - 1;
        int current = 0;
        while(doll[current].parent == current + 1){
            current++;
        }
        timer -= 2 * current;
        out.print(Integer.toString(timer));
    }   
    private static double sqr(double arg){
        return arg * arg;
    }
    private static int sqr(int arg){
        return arg * arg;
    }
}
class Doll{
    public boolean free;
    public int parent;  
    public Doll(){
        free = false;
        parent = -1;
    }
}
class FastScanner extends BufferedReader {
    boolean isEOF;
    
    public FastScanner(InputStream is) {
        super(new InputStreamReader(is));
    }
    
    public int read() {
        try {
            int ret = super.read();
            if (isEOF && ret < 0) {
                throw new InputMismatchException();
            }
            isEOF = ret == -1;
            return ret;
        } catch (IOException e) {
            throw new InputMismatchException();
          }
    }

    public String next() {
        StringBuilder sb = new StringBuilder();
        int c = read();
        while (isWhiteSpace(c)) {
            c = read();
        }
        while (!isWhiteSpace(c)) {
            sb.appendCodePoint(c);
            c = read();
        }
        return sb.toString();
    }

    static boolean isWhiteSpace(int c) {
        return c >= -1 && 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 (!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;
    }

}

class FastPrinter extends PrintWriter {
    public FastPrinter(OutputStream out) {
        super(out);
    }
    public FastPrinter(Writer out) {
        super(out);
    }
    public FastPrinter(String fileName) throws FileNotFoundException {
        super(fileName);
    }  
    public FastPrinter(File file) throws FileNotFoundException {
        super(file);
    }

}

class Extra {
    private static final String Alphabet = "abcdefghijklmnopqrstuvwxyz";
    public static String GetAlphabet(){
        return Alphabet;
    }
}