import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

/**
 * @author Don Li
 */
public class Matryoshkas {
    void solve() {
        int n = in.nextInt(), k = in.nextInt();
        int breaks = 0, components = 0;
        for (int i = 0; i < k; i++) {
            int m = in.nextInt();
            int[] A = new int[m];
            for (int j = 0; j < m; j++) A[j] = in.nextInt();
            int b = 0;
            for (int p = 0; p < m; ) {
                if (A[p] == 1) {
                    int q = p;
                    while (q + 1 < m && A[q + 1] - A[q] == 1) q++;
                    if (q != m - 1) b++;
                    p = q + 1;
                } else {
                    if (p != m - 1) b++;
                    p++;
                }
            }
            breaks += b;
            components += b + 1;
        }
        out.println(breaks + components - 1);
    }

    public static void main(String[] args) {
        in = new FastScanner(new BufferedReader(new InputStreamReader(System.in)));
        out = new PrintWriter(System.out);
        new Matryoshkas().solve();
        out.close();
    }

    static FastScanner in;
    static PrintWriter out;

    static class FastScanner {
        BufferedReader in;
        StringTokenizer st;

        public FastScanner(BufferedReader in) {
            this.in = in;
        }

        public String nextToken() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(in.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(nextToken());
        }

        public long nextLong() {
            return Long.parseLong(nextToken());
        }

        public double nextDouble() {
            return Double.parseDouble(nextToken());
        }
    }
}
