def main():
    ts = input().split()
    n = int(ts[0])
    k = int(ts[1])
    ans = 0
    b=None
    for _ in range(k):
        ts = [int(t) for t in input().split()]
        ts = ts[1:]
        i = 0
        while i<len(ts) and ts[i]==i+1:
            i+=1
        if i==0:
            ans += len(ts)-1
        else:
            assert b==None
            b = i
            ans += len(ts)-i
    print(ans+n-b)
    
if __name__=='__main__':
    main()
    