N,M,A = map(int,input().split()) G = [[] for _ in range(N + 1)] for _ in range(M): l,r,p = map(int,input().split()) G[r].append((l,p)) dp = [0] * (N + 1) _max = 0 index = 0 for i in range(1,N + 1): dp[i] = _max - A for l,p in G[i]: dp[i] = max(dp[i],dp[l-1] + p - A) if dp[i] > _max: _max = dp[i] index = i dp[N] += A print(max(dp))