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

    cost = [1 for _ in range(n - 1)]

    computation = 0
    for _ in range(k):
        a = [int(t) for t in input().split()]
        for i in range(1, len(a) - 1):
            if a[i] + 1 == a[i + 1]:
                cost[i] = 0
            else:
                computation += 1

    computation += sum(cost)

    print(computation)


if __name__ == '__main__':
    main()