#!/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 = []
y = 0
for l in la:
    a = 0
    t = 0
    for i in range(len(l)-1):
        if not l[i]+1 == l[i+1]:
            x.append((l[a], l[i]))
            a = i+1
            t+=1
    x.append((l[a], l[len(l)-1]))
    y+=t

x.sort(key = lambda x:x[0])
ans = 0
for i in range(len(x)-1):
    if x[i+1][1] == x[i+1][0]:
        ans += 1
    else:
        ans += (x[i+1][1] - x[i+1][0] + 1)*2

print ans + y
