n, m = list(map(int, input().split()))
a = [[0] for i in range(m)]
for i in range(m):
    a[i] = list(map(int, input().split()))
b = [0] * (n + 1)
for i in range(m):
    for j in range(1, a[i][0]):
        b[a[i][j]] = a[i][j + 1]
    b[a[i][a[i][0]]] = -2
for i in range(1, n + 1):
    if b[i] != i + 1:
        k = i
        break
#print(k)
print(2 * n - m - 2 * k + 1)
