import java.io.*; import java.util.*; import java.util.function.*; import java.util.stream.*; public class Main { static long[] dp; static List speeches = new ArrayList<>(); static int wake; static int sleep; static TreeMap compress = new TreeMap<>(); public static void main(String[] args) throws Exception { Scanner sc = new Scanner(); int n = sc.nextInt(); wake = sc.nextInt(); sleep = sc.nextInt(); for (int i = 0; i < n; i++) { Speech current = new Speech(sc.nextInt(), sc.nextInt(), sc.nextInt()); if (current.length() <= wake) { speeches.add(current); } } Collections.sort(speeches); for (int i = 0; i < speeches.size(); i++) { compress.put(speeches.get(i).end, i); } compress.put(Integer.MIN_VALUE, -1); dp = new long[speeches.size()]; Arrays.fill(dp, -1); System.out.println(dfw(speeches.size() - 1)); } static long dfw(int idx) { if (idx < 0) { return 0; } if (dp[idx] < 0) { dp[idx] = Math.max(dfw(idx - 1), dfw(compress.floorEntry(speeches.get(idx).start - sleep).getValue()) + speeches.get(idx).value); } return dp[idx]; } static class Speech implements Comparable { int start; int end; int value; public Speech(int start, int end, int value) { this.start = start; this.end = end; this.value = value; } public int compareTo(Speech another) { return end - another.end; } public int length() { return end - start; } } } class Scanner { BufferedReader br; StringTokenizer st = new StringTokenizer(""); StringBuilder sb = new StringBuilder(); public Scanner() { try { br = new BufferedReader(new InputStreamReader(System.in)); } catch (Exception e) { } } public int nextInt() { return Integer.parseInt(next()); } public long nextLong() { return Long.parseLong(next()); } public double nextDouble() { return Double.parseDouble(next()); } public String next() { try { while (!st.hasMoreTokens()) { st = new StringTokenizer(br.readLine()); } } catch (Exception e) { e.printStackTrace(); } finally { return st.nextToken(); } } }