//package cf556;

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class C {

    private static int getCrimeTime(List<List<Integer>> mlists) {
        int destructionTime = 0;
        int constructionTime = 0;
        for (List<Integer> row : mlists) {
            int reusability = getReusability(row);
            destructionTime += row.size() - reusability;
            constructionTime += row.size() - reusability + 1;
        }
        --constructionTime;
        return destructionTime + constructionTime;
    }

    private static int getReusability(List<Integer> row) {
        if (row.get(0) != 1) {
            return 1;
        }
        for (int i = 1; i <= row.size(); ++i) {
            if (row.get(i - 1) != i) {
                return i - 1;
            }
        }
        return row.size();
    }

    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int n = s.nextInt();
        int k = s.nextInt();
        List<List<Integer>> mlists = new ArrayList<>();
        for (int rowIndex = 0; rowIndex < k; ++rowIndex) {
            int mCount = s.nextInt();
            List<Integer> row = new ArrayList<>();
            for (int colIndex = 0; colIndex < mCount; ++colIndex) {
                row.add(s.nextInt());
            }
            mlists.add(row);
        }
        System.out.println(getCrimeTime(mlists));
    }
}
