import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;

/**
 * User: dmitry
 */
public class Main {
    public static InputStream is = System.in;
    public static BufferedReader br = new BufferedReader(new InputStreamReader(is));
    public static StringTokenizer stok;

    public static String next() {
        String nxt;
        try {
            if (stok != null && stok.hasMoreElements()) return stok.nextToken();
            if ((nxt = br.readLine()) != null) {
                stok = new StringTokenizer(nxt);
                if (stok.hasMoreElements()) return stok.nextToken();
            } else return null;
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }

    public static Integer nextInt() {
        return Integer.valueOf(next());
    }

    public static void main(String[] args) {
        int n = nextInt();
        int k = nextInt();

        List<List<Integer>> chains = new ArrayList<>();
        int ans = 0;
        for (int i = 0; i < k; i++) {
            chains.add(new ArrayList<Integer>());
            int m = nextInt();
            List<Integer> kc = chains.get(i);
            for (int j = 0; j < m; j++) {
                kc.add(nextInt());
            }
            for (int j = 1; j < kc.size(); j++) {
                if (kc.get(j) - kc.get(j - 1) > 1) {
                    ans += (kc.size() - j) * 2;
                    break;
                }
            }
        }
        System.out.println(ans + k - 1);

    }
}