# coding: utf-8 # Your code here! n,m,a = [int(i) for i in input().split()] lrp = [[int(i) for i in input().split()] for _ in range(m)] + [[1,i,0] for i in range(1,n+1)] + [[i,n,0] for i in range(1,n+1)] lrp.sort(key = lambda x: x[1]) inf = 1e18 dp = [-inf]*(n+1) dp[0] = 0 for l,r,p in lrp: l-=1 r-=1 if r != n-1: dp[r+1] = max(dp[r+1], dp[l]+p-a) else: dp[r+1] = max(dp[r+1], dp[l]+p) #print(dp) print(max(dp))