#!/usr/bin/env python
# encoding: utf-8

n, k = [int(x) for x in raw_input().split(' ')]
la = []
for i in range(k):
    l = [int(x) for x in raw_input().split(' ')]
    la.append(l[1:])

x = 0
y = 0
for l in la:
    t = 0
    for i in range(len(l)-1):
        if not l[i]+1 == l[i+1]:
            t+=1
    x += t
    y += (t+1)

print x+y-1
