import java.util.Scanner;

/**
 * Created by aitch_nu on 9/9/15.
 */
public class CaseOfMatryoshkas {

    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int count = 0;
        int cost = 0;
        for(int i=0;i<k;i++){
            int m = sc.nextInt();
            int pvs = sc.nextInt();
            int reduce = 0;
            if(pvs == 1) {
                boolean broken = false;

                for (int j = 1; j < m; j++) {
                    int current = sc.nextInt();
                    if ((pvs + 1) == current && !broken) reduce++;
                    else broken = true;
                    pvs = current;
                }
            }else{
                for (int j = 1; j < m; j++) sc.nextInt();
            }
            cost = cost + m - 1 - reduce;
            count = count + m - reduce;
        }
        System.out.println(cost + count -1);
    }
}
