import java.util.Arrays;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.BufferedReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.IOException;
import java.util.StringTokenizer;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskC solver = new TaskC();
		solver.solve(1, in, out);
		out.close();
	}
}

class TaskC {
    public void solve(int testNumber, InputReader in, PrintWriter out) {
        int n = in.nextInt();
        int k = in.nextInt();
        int pre[] = new int[100001];
        int val[] = new int[n];
        int i = 0;
        while (k > 0) {
            int m = in.nextInt();
            val[i] = in.nextInt();
            pre[val[i]] = -1;
            i++;
            while (m > 1) {
                val[i] = in.nextInt();
                pre[val[i]] = val[i - 1];
                i++;
                m--;
            }
            k--;
        }
        Arrays.sort(val);
        boolean split = false;
        int counter = 0;
        for (int j = 1; j < n; j++) {
            int x = val[j];
            if (split == true) {
                if (pre[x] == -1) {
                    counter++;
                } else {
                    counter += 2;
                }
            } else {
                int bfX = val[j - 1];
                if (pre[x] != bfX) {
                    split = true;
                    if (pre[x] == -1) {
                        counter++;
                    } else {
                        counter += 2;
                    }
                }
            }
        }
        out.println(counter);
    }
}

class InputReader {
    StringTokenizer tokenizer;
    BufferedReader reader;

    public InputReader(InputStream stream) {
        tokenizer = null;
        reader = new BufferedReader(new InputStreamReader(stream), 32768);
    }

    public String next() {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

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

}
