import java.util.Scanner;


public class Main {

    public static void main(String[] args) throws Exception
    {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int k = in.nextInt();

        int count = k-1;
        for (int i = 0; i < k; i++)
        {
            int m = in.nextInt();

            int x = in.nextInt();
            boolean flag = true;
            for (int j = 1; j < m; j++)
            {
                int y = in.nextInt();
                if ((flag) && (y - x > 1))
                {
                    count += (m - j) * 2;
                    flag = false;
                }
                x = y;
            }
        }
        System.out.println(count);

    }
}