import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner in = new Scanner(System.in);

        int n, k;
        n = in.nextInt();
        k = in.nextInt();

        int ans = 0;
        int totalSubchains = 0;
        while (k > 0) {
            k--;
            int currentChainSize = in.nextInt();
            int[] currentChain = new int[currentChainSize];
            for (int i = 0; i < currentChainSize; i++) {
                currentChain[i] = in.nextInt();
            }

            int costCurrentChain = 0;
            int consecutive = 0;
            int howManySubchains = 1;
            for (int i = currentChainSize - 2; i >= 0; i--) {
                if (currentChain[i + 1] - currentChain[i] > 1) {
                    costCurrentChain += consecutive + 1;
                    consecutive = 0;
                    howManySubchains++;
                } else {
                    consecutive++;
                }
            }

            ans += costCurrentChain;
            totalSubchains += howManySubchains;

        }
        ans += totalSubchains - 1;
        System.out.println(ans);

    }
}
