import collections, functools, sys sys.setrecursionlimit(2 ** 31 - 1) n, m, a = map(int, input().split()) d = collections.defaultdict(int) for _ in range(m): l, r, p = map(int, input().split()) d[(l - 1, r)] = p @functools.lru_cache(maxsize=None) def f(current): ans = d[(current, n)] # 線を引かない場合 for nxt in range(current + 1, n): ans = max(ans, f(nxt) + d[(current, nxt)] - a) return ans print(f(0))