import java.io.*; import java.util.*; import java.util.function.*; import java.util.stream.*; public class Main { static List> dp = new ArrayList<>(); static List speeches = new ArrayList<>(); static int wake; static int sleep; 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); dp.add(new HashMap<>()); } } Collections.sort(speeches); System.out.println(dfw(speeches.size() - 1, Integer.MAX_VALUE)); } static long dfw(int idx, int v) { if (idx < 0) { return 0; } if (v < speeches.get(idx).end) { return dfw(idx - 1, v); } v = Math.min(v, speeches.get(idx).end); if (!dp.get(idx).containsKey(v)) { dp.get(idx).put(v, Math.max(dfw(idx - 1, v), dfw(idx - 1, speeches.get(idx).start - sleep) + speeches.get(idx).value)); } return dp.get(idx).get(v); } 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(); } } }