import java.util.Scanner;

/**
 * Created by Majid on 6/24/2015.
 */
public class C {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int n = input.nextInt();
        int k = input.nextInt();
        int biggestChain = 0;
        int moves = 0;
        for (int i = 1; i < k; i++) {
            int chainNum = input.nextInt();
            int completeChain = 0;
            for (int j = 0; j < chainNum; j++)
                if (input.nextInt() == j + 1)
                    completeChain++;
            if (biggestChain < completeChain)
                biggestChain = completeChain;
            moves += chainNum - completeChain;
        }

        System.out.println(moves + n - biggestChain);
        input.close();
    }
}
