import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;


public class Codeforces556C {
	public static void main(String[] args) {
		try
		{
			BufferedReader f = new BufferedReader(new InputStreamReader(System.in));
			StringTokenizer st = new StringTokenizer(f.readLine());
			int n = Integer.parseInt(st.nextToken());
			int k = Integer.parseInt(st.nextToken());
			int numBreaks = 0;
			int numPieces = 0;
			for(int i = 0; i < k; i++)
			{
				st = new StringTokenizer(f.readLine());
				int m = Integer.parseInt(st.nextToken());
				int current = Integer.parseInt(st.nextToken());
				numPieces++;
				int j = 0;
				for(j = 1; j < m; j++)
				{
					int next = Integer.parseInt(st.nextToken());
					if(next != current + 1)
					{
						break;
					}
					current = next;
				}
				numPieces += m-j;
				numBreaks += m-j;
			}
			System.out.println(numBreaks + numPieces - 1);
		}
		catch(IOException e)
		{
			System.out.println(e);
		}

	}

}
