import sys

s = sys.stdin.readline().split()
n = int(s[0])
k = int(s[1])

chains = []
oper = 0
start = 0
for i in xrange(k):
    s = sys.stdin.readline().split()
    m = int(s[0])
    l = [int(c) for c in s[1:]]
    if l[0] == 1:
        for ii in xrange(2, m):
            if ii == l[ii-1]:
                start += 1
            else:                
                break
        oper += m - 1 - start
            
    else:
        oper += m - 1

#print oper
#print start

print oper - start + n - 1
    
        
    
    
    
    
    