import collections 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 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))