n, k = map(int, raw_input().split(" "))

splits = 0
components = 0

for i in xrange(k):
  l = map(int, raw_input().split(" "))
  prev = l[1]
  new_splits = 0

  for j in xrange(2, l[0] + 1):
    if l[j] - prev == 1:
      continue
    else:
      new_splits = l[0] - j + 1
      break

  splits += new_splits
  components += new_splits + 1

print splits + components - 1