import java.util.*;
import java.io.*;

public class c310{

  public static void main(String[] args) {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    try{
      String[] s = br.readLine().split(" ");
      int n = Integer.parseInt(s[0]);
      int k = Integer.parseInt(s[1]);
      int[] l = new int[k];
      for(int i=0; i<k ;i++){
        s = br.readLine().split(" ");
        if(s[1].equals("1")){
          int j=1,count=0;
          while((j<s.length-1)&&(Integer.parseInt(s[j+1])==Integer.parseInt(s[j])+1)){
            j++;
          }
          l[i] = Integer.parseInt(s[0])-j+1;
        }
        else l[i] = Integer.parseInt(s[0]);
      }
      int brk=0,join=0;
      for(int i=0;i<k;i++){
        brk += l[i]-1;
        join += l[i];
      }
      System.out.println(brk+join-1);
    }catch(Exception e){
    e.printStackTrace();
  }
}

}
