def count_continuous(a):
    total = 0
    for i in range(len(a) - 1):
        if a[i] + 1 == a[i + 1]:
            total += 1

    return total


def main():
    n, k = [int(t) for t in input().split()]

    p = 0
    for _ in range(k):
        a = [int(t) for t in input().split()]
        if a[1] == 1:
            p = count_continuous(a[1:])

    cost = n - 1 - p
    bind = n - k - p
    cost += bind

    print(cost)


if __name__ == '__main__':
    main()