import java.util.Scanner;

public class C {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int totalActions = n - 1; //to build
        for (int i = 0; i < k; i++) {
            int currentLength = sc.nextInt();
            totalActions += currentLength - 1; //to destroy
            int[] curLine = new int[currentLength];
            for (int j = 0; j < currentLength; j++) {
                curLine[j] = sc.nextInt();
            }
            if (curLine[0] == 1) {
                int len = 0;
                for (int j = 1; j < currentLength; j++) {
                    if (curLine[j] == j + 1) {
                        len++;
                    } else {
                        break;
                    }
                }
                totalActions -= len * 2;
            }

        }
        System.out.println(totalActions);
    }
}
