n, m = map(int, input().split())
chains = [[int(x) for x in input().split()][1:] for i in range(m)]
ans = 0
for chain in chains:
    if chain == [x for x in range(1, len(chain) + 1)]:
        n -= len(chain) - 1
    else:
        ans += len(chain) - 1
print(n - 1 + ans)
