N,M,A = map(int,input().split()) lsscore = [[] for i in range(N+1)] for i in range(M): l,r,p = map(int,input().split()) lsscore[r].append((l,p)) dp = [float('INF')]*(N+1) dp[0] = 0 mm = 0 for i in range(1,N): mm = max(dp[i-1],mm) s = mm-A for j,p in lsscore[i]: s = max(dp[j-1]+p-A,s) dp[i] = s mm = max(dp[N-1],mm) s = mm for j,p in lsscore[N]: s = max(dp[j-1]+p,s) dp[N] = s print(max(dp))