
//MohammedElkady
import java.util.*;
public class Hell {
static int size;

    public static void main(String[] args) {
        Scanner in=new Scanner(System.in);
       int n=in.nextInt();
       int k=in.nextInt(),m=k;
       while(k-->0){
       int x=1;
       int mi=in.nextInt();
       for(int i=0;i<mi;i++){
       int c=in.nextInt();
       if(c==x){size--;x++;}
       else x=-1;
       }
       }
        System.out.println(n+size+(n-(m-size-1)));
}
}
class HashTable{
List[]Table;
HashTable(int size){
Table=new List[size];
while(size-->0){
Table[size]=new ArrayList();
}
}
void Hashing(int kay,int value){
Table[kay].add(value);
}
void Delet(int key,int value){
for(int i=0;i<Table[key].size();i++)
    if(value==(int)Table[key].get(i)){
        Table[key].remove(i);i--;}
}
ArrayList getTable(int key){
    return (ArrayList) Table[key];

}
void Uptodate(int key ,int value , int nextvalue){
for(int i=0;i<Table[key].size();i++)
    if(Table[key].get(i).equals(value)){
        Table[key].remove(i);Table[key].add(nextvalue);i--;}

}
}