import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.StringTokenizer;

public class C {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(System.out);
        StringTokenizer st;

        st = new StringTokenizer(br.readLine());
        int n = Integer.parseInt(st.nextToken()), m = Integer.parseInt(st.nextToken());
        int ans = 0, start, end = 0;

        for (int i = 0, l; i < m; i++) {
            st = new StringTokenizer(br.readLine());
            l = Integer.parseInt(st.nextToken());

            start = Integer.parseInt(st.nextToken());
            if (start == 1) {
                end = start;
                for (int j = 1; j < l; j++) {
                    int current = Integer.parseInt(st.nextToken());
                    if (current == end + 1) {
                        end = current;
                    } else {
                        ans += (l - j);
                        break;
                    }
                }
            } else {
                ans += (l - 1);
            }
        }
        ans += (n - end);
        out.println(ans);
        out.close();
    }
}
