

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

public class D2C {

    public static void main(String args[]) throws Exception {
        int ret = 0;

        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[] chain = new int[n];
        int getout = 0;
        for (int i = 0; i < k; i++) {
            line = br.readLine();
            tokens = line.split(" ");
            int m = Integer.parseInt(tokens[0]);
            int pre = -1;
            for (int j = 0; j < m; j++) {
                int a = Integer.parseInt(tokens[j + 1]) - 1;    // 1-based to 0-based
                chain[a] = i;
                if (pre != -1 && a != pre + 1) {
                    ++getout;
                }
                pre = a;
            }
        }

        //System.out.println(Arrays.toString(chain));
        //System.out.println(gets);

        int putin = 0;
        for (int i = 1; i < n; i++) {
            if (chain[i - 1] != chain[i]) {
                ++putin;
            }
        }
        ret = getout + putin;
        System.out.println(ret);

    }

}
