# print ("Enter n and k")
two = input().split()
n = int(two[0])
k = int(two[1])

if (n==1 or k==1):
    print ("0")
else:
    seta = []
    whichset = [0 for i in range(n+1)]
    for i in range(k):
        # print ("Enter the next row")
        therow = input().split()
        num = int(therow[0])
        theset = set()
        for j in range(num):
            nextval = int(therow[j+1])
            theset.add(nextval)
            whichset[nextval] = i
        seta.append(theset)

    # Is the biggest one singleton or not?
    answer = 0
    for i in range(k):
        if n in seta[i]:
            if len(seta[i]) > 1:
                answer = 1
                # print (str(n) + " is removed--answer is " + str(answer))
            else:
                answer = 0
                # print (str(n) + " is removed--answer is " + str(answer))
            seta[i].remove(n)
            n = n - 1
            break
        
    while (n >= 1):   # Still more to process
        # Find the correct set from the array whichset
        setnum = whichset[n]
        #  This is the right one--first check for a singleton
        if len(seta[setnum]) == 1:
            answer = answer + 1
            seta[setnum].remove(n)
            # print (str(n) + " is removed--current answer is " + str(answer))
            n = n - 1
        else:   # Can the whole bunch go (MUST BE CONSEQ DOWN TO ONE)
            if len(seta[setnum]) == n:  # They are all there! We are done!
                answer = answer + 1
                # print ("Big removal! We are done with answer " + str(answer))
                n = 0
                break
            else:
                seta[setnum].remove(n)
                # print (str(n) + " is removed")
                n = n - 1
            if (len(seta[setnum]) == 0):
                answer = answer + 1
            else:
                answer = answer + 2
            # print ("The current answer is " + str(answer))

    print (answer)
                
        
    
