import sys


# def split(arr):
#     res = []

#     current_rising = []
#     i = 0
#     while i < len(arr) - 1:
#         if arr[i] + 1 == arr[i + 1]:
#             current_rising.append(arr[i])
#             i += 1
#         else:
#             if (current_rising):
#                 current_rising.append(arr[i])
#                 res.append(current_rising)
#                 current_rising = []
#             else:
#                 res.append(arr[i])
#             i += 1
#     if current_rising:
#         current_rising.append(arr[i])
#         res.append(current_rising)
#     else:
#         res.append(arr[i])

#     return res

def split(arr):
    i = 1
    while i < len(arr):
        if arr[i] - 1 != arr[i - 1]:
            break
        i += 1

    return arr[:i], arr[i:]

n, k = map(int, sys.stdin.readline().split())

arrs = []

for i in xrange(k):
    arrs.append(map(int, sys.stdin.readline().split())[1:])

parts = 0
dis = 0
for arr in arrs:
    seq, oth = split(arr)
    dis += len(arr) - len(seq)
    parts += len(oth) + (1 if seq else 0)

sys.stdout.write(str(parts - 1 + dis) + "\n")
