import java.util.Scanner;
public class TaskC {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		// TODO Auto-generated method stub
		int n=sc.nextInt();
		int k=sc.nextInt();
		int curL,cur;
		int total=n-1;
		int bonus=0;
		for(int i=0;i<k;i++)
		{
			curL=sc.nextInt();
			cur=sc.nextInt();
			
			if(cur==1)
			{
				boolean flag=true;
				for(int j=2;j<=curL;j++)
				{
					cur=sc.nextInt();
					if(cur==j&&flag)
					{
						bonus+=2;
					}
					else
					{
						flag=false;
					}
				}
				total+=curL-1-bonus;
			}
			else
			{
				for(int j=2;j<=curL;j++)
				{
					cur=sc.nextInt();
				}
				total+=curL-1;
			}
		}
		System.out.println(total);
	}
}
