Joisino is planning to record N TV programs with recorders.

The TV can receive C channels numbered 1 through C.

The i-th program that she wants to record will be broadcast from time s_i to time t_i (including time s_i but not t_i) on Channel c_i.

Here, there will never be more than one program that are broadcast on the same channel at the same time.

When the recorder is recording a channel from time S to time T (including time S but not T), it cannot record other channels from time S-0.5 to time T (including time S-0.5 but not T).

Find the minimum number of recorders required to record the channels so that all the N programs are completely recorded.

Constraints

* 1≤N≤10^5
* 1≤C≤30
* 1≤s_i<t_i≤10^5
* 1≤c_i≤C
* If c_i=c_j and i≠j, either t_i≤s_j or s_i≥t_j.
* All input values are integers.

Input

Input is given from Standard Input in the following format:


N C
s_1 t_1 c_1
:
s_N t_N c_N


Output

When the minimum required number of recorders is x, print the value of x.

Examples

Input

3 2
1 7 2
7 8 1
8 12 1


Output

2


Input

3 4
1 3 2
3 4 4
1 4 3


Output

3


Input

9 4
56 60 4
33 37 2
89 90 3
32 43 1
67 68 3
49 51 3
31 32 3
70 71 1
11 12 3


Output

2
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.util.List;
import java.util.NoSuchElementException;
import java.util.StringJoiner;
import java.util.TreeSet;

class Main {

    static PrintWriter out;
    static InputReader sc;

    public static void main(String[] args) {
        sc = new InputReader(System.in);
        out = new PrintWriter(System.out);
        solve();
        out.flush();
    }

    static void solve() {
        final int INF = Integer.MAX_VALUE / 3;
        int N = sc.nextInt();
        int C = sc.nextInt();
        List<List<Pair>> ps = new ArrayList<>();
        for (int i = 0; i < C; i++) {
            ps.add(new ArrayList<>());
        }
        for (int i = 0; i < N; i++) {
            int s = sc.nextInt();
            int t = sc.nextInt();
            int c = sc.nextInt() - 1;
            ps.get(c).add(new Pair(s, t));
        }
        boolean[][] use = new boolean[C][(int) 1e5 + 1];
        for (int i = 0; i < C; i++) {
            for (int j = 0; j < ps.get(i).size(); j++) {
                for (int k = ps.get(i).get(j).s - 1; k < ps.get(i).get(j).t; k++) {
                    use[i][k] = true;
                }
            }
        }
        int ans = 0;
        for (int i = 0; i < (int) 1e5 + 1; i++) {
            int cnt = 0;
            for (int j = 0; j < C; j++) {
                if (use[j][i]) {
                    cnt++;
                }
            }
            ans = Math.max(ans, cnt);
        }
        out.println(ans);
    }

    /**
     * C++のPairと同じ
     */
    public static class Pair implements Comparable<Pair> {
        int s;
        int t;

        public Pair(int first, int second) {
            this.s = first;
            this.t = second;
        }

        @Override
        public int hashCode() {
            return Integer.valueOf(this.s + this.t).hashCode();
        }

        @Override
        public boolean equals(Object obj) {
            if (this == obj) {
                return true;
            }
            if (!(obj instanceof Pair)) {
                return false;
            }
            Pair pair = (Pair) obj;
            return this.s == pair.s && this.t == pair.t;
        }

        @Override
        public int compareTo(Pair o) {
            return Integer.compare(this.s, o.s);
        }

        @Override
        public String toString() {
            return String.format("{%d,%d}", this.s, this.t);
        }

    }

    /**
     * 座標を圧縮し、長さを返す O(n log(n)).
     *
     * <pre>
     * {@code
     * W = compress(x1, x2, W);
     * H = compress(y1, y2, H);
     *  }
     * </pre>
     *
     * みたいに使って圧縮する
     *
     * @param x1
     * @param x2
     * @param w
     * @return 座標圧縮後の長さ
     */
    public static int compress(int[] x1, int[] x2, int w) {
        int n = x1.length;
        // 自動でソートしてくれる
        TreeSet<Integer> set = new TreeSet<>();
        // 両端を入れないと端の余白が消える
//        set.add(0);
//        set.add(w);
        for (int i = 0; i < n; i++) {
            set.add(x1[i]);
            set.add(x2[i]);
        }
        int nw = set.size();
        Integer[] x = set.toArray(new Integer[nw]);
        for (int i = 0; i < n; i++) {
            x1[i] = Arrays.binarySearch(x, x1[i]);
            x2[i] = Arrays.binarySearch(x, x2[i]);
        }
        return nw - 1;
    }

    static void debug(Object... args) {
        StringJoiner j = new StringJoiner(" ");
        for (Object arg : args) {
            if (arg == null) {
                j.add("null");
            } else if (arg instanceof int[]) {
                j.add(Arrays.toString((int[]) arg));
            } else if (arg instanceof long[]) {
                j.add(Arrays.toString((long[]) arg));
            } else if (arg instanceof double[]) {
                j.add(Arrays.toString((double[]) arg));
            } else if (arg instanceof char[]) {
                j.add(Arrays.toString((char[]) arg));
            } else if (arg instanceof boolean[]) {
                j.add(Arrays.toString((boolean[]) arg));
            } else if (arg instanceof Object[]) {
                j.add(Arrays.toString((Object[]) arg));
            } else {
                j.add(arg.toString());
            }
        }
        System.err.println(j.toString());
    }

    static class InputReader {

        private InputStream in;
        private byte[] buffer = new byte[1024];
        private int curbuf;
        private int lenbuf;

        public InputReader(InputStream in) {
            this.in = in;
            this.curbuf = this.lenbuf = 0;
        }

        public boolean hasNextByte() {
            if (this.curbuf >= this.lenbuf) {
                this.curbuf = 0;
                try {
                    this.lenbuf = this.in.read(this.buffer);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (this.lenbuf <= 0) {
                    return false;
                }
            }
            return true;
        }

        private int readByte() {
            if (this.hasNextByte()) {
                return this.buffer[this.curbuf++];
            } else {
                return -1;
            }
        }

        private boolean isSpaceChar(int c) {
            return !(c >= 33 && c <= 126);
        }

        private void skip() {
            while (this.hasNextByte() && this.isSpaceChar(this.buffer[this.curbuf])) {
                this.curbuf++;
            }
        }

        public boolean hasNext() {
            this.skip();
            return this.hasNextByte();
        }

        public String next() {
            if (!this.hasNext()) {
                throw new NoSuchElementException();
            }
            StringBuilder sb = new StringBuilder();
            int b = this.readByte();
            while (!this.isSpaceChar(b)) {
                sb.appendCodePoint(b);
                b = this.readByte();
            }
            return sb.toString();
        }

        public int nextInt() {
            if (!this.hasNext()) {
                throw new NoSuchElementException();
            }
            int c = this.readByte();
            while (this.isSpaceChar(c)) {
                c = this.readByte();
            }
            boolean minus = false;
            if (c == '-') {
                minus = true;
                c = this.readByte();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9') {
                    throw new InputMismatchException();
                }
                res = res * 10 + c - '0';
                c = this.readByte();
            } while (!this.isSpaceChar(c));
            return minus ? -res : res;
        }

        public long nextLong() {
            if (!this.hasNext()) {
                throw new NoSuchElementException();
            }
            int c = this.readByte();
            while (this.isSpaceChar(c)) {
                c = this.readByte();
            }
            boolean minus = false;
            if (c == '-') {
                minus = true;
                c = this.readByte();
            }
            long res = 0;
            do {
                if (c < '0' || c > '9') {
                    throw new InputMismatchException();
                }
                res = res * 10 + c - '0';
                c = this.readByte();
            } while (!this.isSpaceChar(c));
            return minus ? -res : res;
        }

        public double nextDouble() {
            return Double.parseDouble(this.next());
        }

        public int[] nextIntArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = this.nextInt();
            }
            return a;
        }

        public long[] nextLongArray(int n) {
            long[] a = new long[n];
            for (int i = 0; i < n; i++) {
                a[i] = this.nextLong();
            }
            return a;
        }

        public char[][] nextCharMap(int n, int m) {
            char[][] map = new char[n][m];
            for (int i = 0; i < n; i++) {
                map[i] = this.next().toCharArray();
            }
            return map;
        }
    }
}