import java.io.PrintWriter;
import java.util.*;
public class b 
{
	public static void main(String[] arg)
	{
		new b();
	}
	public b()
	{
		Scanner in = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		int n = in.nextInt();
		int k = in.nextInt();
		int comp = 0;
		int split = 0;
		for(int i = 0; i < k; i++)
		{
			int size = in.nextInt();
			int[] arr = new int[size];
			for(int j = 0; j < size; j++)
			{
				arr[j] = in.nextInt();
			}
			for(int j = 1; j < size; j++)
			{
				if(arr[j]-1 != arr[j-1])
				{
					split++;
					comp++;
				}
			}
			comp++;
		}
		out.println((comp-1)+split);
		in.close(); out.close();
	}
}
