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 sub1size = 0;
        int howManyCuts = 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();
            }


            if (currentChain[0] == 1) {
                while (sub1size < currentChainSize && currentChain[sub1size] == sub1size + 1) sub1size++;
                howManyCuts += currentChainSize - sub1size;
            } else {
                howManyCuts += currentChainSize - 1;
            }



        }

//        System.out.println("howManyCuts " + howManyCuts);
//        System.out.println("n " + n);
//        System.out.println("sub1size " + sub1size);
        System.out.println(howManyCuts + n - sub1size);

    }
}
