

import java.io.BufferedReader;
import java.io.InputStreamReader;

public class D2C {

    public static void main(String args[]) throws Exception {
        // Announcement: It is not possible to put a matryoshka A inside the matryoshka B if matryoshka B is already nested in some other matryoshka C.

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String line;
        String[] tokens;

        line = br.readLine();
        tokens = line.split(" ");
        int n = Integer.parseInt(tokens[0]);
        int k = Integer.parseInt(tokens[1]);

        int getout = 0;
        int firstSeqLength = 0;
        for (int i = 0; i < k; i++) {
            line = br.readLine();
            tokens = line.split(" ");
            int m = Integer.parseInt(tokens[0]);
            int pre = -1;
            boolean fistSequence = 0 == Integer.parseInt(tokens[1]) - 1;
            for (int j = 0; j < m; j++) {
                int a = Integer.parseInt(tokens[j + 1]) - 1;    // 1-based to 0-based
                if (fistSequence) {
                    if (pre != -1 && a != pre + 1) {
                        ++getout;
                        fistSequence = false;
                    } else {
                        ++firstSeqLength;
                    }
                } else {
                    ++getout;
                }
                pre = a;
            }
        }
        getout -= k - 1;

        int putin = n - firstSeqLength;

        System.out.println(getout + putin);

    }

}