num_dolls, num_chains = map(int, input().split())
total = num_dolls - 1
for i in range(num_chains):
  chain = list(map(int, input().split()))
  chain.pop(0)
  total += len(chain) - 1
  if 1 in chain:
    pos = chain.index(1) + 1
    while pos < len(chain) and chain[pos] == chain[pos-1] + 1:
      total -= 2
      pos += 1
print(total)
