A coder cannot sit and code all day. Sometimes it is a good idea to rise from the desk, have a rest, have small talk with colleagues and even play. The coders of the F company have their favorite ball game.

Let's imagine the game on the plane with a cartesian coordinate system. The point (0, 0) contains the player who chooses an arbitrary direction and throws a ball in that direction. The ball hits the plane at distance d from the player's original position and continues flying in the same direction. After the ball hits the plane for the first time, it flies on and hits the plane again at distance 2·d from the player's original position and so on (it continue flying in the chosen direction and hitting the plane after each d units). All coders in the F company are strong, so the ball flies infinitely far away.

The plane has n circles painted on it. If a ball hits the plane and hits a circle that is painted on the plane (including its border), then the player gets one point. The ball can hit multiple circles at once and get one point for each of them (if the ball hits some circle x times during the move, the player also gets x points). Count the maximum number of points a player can get if he throws a ball in the arbitrary direction. Note that the direction may have real cooridinates.

Input

The first line contains two space-separated integers — n и d (1 ≤ n ≤ 2·104; 5 ≤ d ≤ 10). Next n lines contain the circles' description. The i-th line contains three space-separated integers xi, yi, ri ( - 10000 ≤ xi, yi ≤ 10000; 1 ≤ r ≤ 50), where (xi, yi, ri) are the coordinates of the center and the radius of the circle, correspondingly. The point (0, 0) is not inside or on the border of some circle.

Output

Print a single integer — the maximum number of points you can get.

Examples

Input

2 5
1 1 1
5 0 1


Output

1


Input

2 5
4 0 3
5 3 1


Output

2


Input

1 10
20 0 10


Output

3
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;
import java.util.ArrayList;
import java.io.OutputStreamWriter;
import java.io.OutputStream;
import java.util.Collection;
import java.io.IOException;
import java.util.stream.Collectors;
import java.io.UncheckedIOException;
import java.util.List;
import java.util.stream.Stream;
import java.io.Closeable;
import java.io.Writer;
import java.util.Comparator;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) throws Exception {
        Thread thread = new Thread(null, new TaskAdapter(), "", 1 << 29);
        thread.start();
        thread.join();
    }

    static class TaskAdapter implements Runnable {
        @Override
        public void run() {
            InputStream inputStream = System.in;
            OutputStream outputStream = System.out;
            FastInput in = new FastInput(inputStream);
            FastOutput out = new FastOutput(outputStream);
            EPlayingTheBall solver = new EPlayingTheBall();
            solver.solve(1, in, out);
            out.close();
        }
    }

    static class EPlayingTheBall {
        public void solve(int testNumber, FastInput in, FastOutput out) {
            int n = in.ri();
            int d = in.ri();
            List<double[]> range = new ArrayList<>(n * 40);
            for (int i = 0; i < n; i++) {
                Point2 c = new Point2(in.ri(), in.ri());
                double theta = GeoConstant.theta(c);
                int r = in.ri();
                double dist = c.abs();
                for (int j = (int) Math.floor(dist) - r; j <= dist + r; j++) {
                    if (j % d != 0 || j <= 0) {
                        continue;
                    }
                    double angle = GeoConstant.triangleAngle(r, j, dist);
                    double left = theta - angle;
                    double right = theta + angle;
                    if (left < 0) {
                        //  assert left + Math.PI * 2 <= Math.PI * 2 - GeoConstant.PREC;
                        range.add(new double[]{left + Math.PI * 2, Math.PI * 2 - GeoConstant.PREC});
                        left = 0;
                    }
                    if (right > Math.PI * 2) {
                        //   assert 0 <= right - Math.PI * 2;
                        range.add(new double[]{0, right - Math.PI * 2});
                        right = Math.PI * 2 - GeoConstant.PREC;
                    }
                    // assert left <= right;
                    range.add(new double[]{left, right});
                }
            }
            range = range.stream().filter(x -> x[0] <= x[1]).collect(Collectors.toList());

            int m = range.size();
            double[][] all = range.toArray(new double[0][]);
            double[][] sortByL = all.clone();
            double[][] sortByR = all.clone();
            Arrays.sort(sortByL, Comparator.comparingDouble(x -> x[0]));
            Arrays.sort(sortByR, Comparator.comparingDouble(x -> x[1]));
            int cnt = 0;
            int sortByLHead = 0;
            int sortByRHead = 0;
            int ans = 0;
            while (sortByLHead < m) {
                assert sortByRHead < m;
                if (sortByL[sortByLHead][0] <= sortByR[sortByRHead][1]) {
                    cnt++;
                    sortByLHead++;
                } else {
                    cnt--;
                    sortByRHead++;
                }
                ans = Math.max(ans, cnt);
            }

            out.println(ans);
        }

    }

    static class GeoConstant {
        public static final double PREC = 1e-10;

        public static double theta(double x, double y) {
            double theta = Math.atan2(y, x);
            if (theta < 0) {
                theta += Math.PI * 2;
            }
            return theta;
        }

        public static double theta(Point2 pt) {
            return theta(pt.x, pt.y);
        }

        public static double triangleAngle(double a, double b, double c) {
            double cosa = (b * b + c * c - a * a) / (2 * b * c);
            return Math.acos(cosa);
        }

    }

    static class Point2 implements Cloneable {
        public double x;
        public double y;

        public Point2(double x, double y) {
            this.x = x;
            this.y = y;
        }

        public Point2() {
            this(0, 0);
        }

        public double square() {
            return dot(this, this);
        }

        public double abs() {
            return Math.sqrt(square());
        }

        public static double dot(Point2 a, Point2 b) {
            return a.x * b.x + a.y * b.y;
        }

        public Point2 clone() {
            try {
                return (Point2) super.clone();
            } catch (CloneNotSupportedException e) {
                throw new RuntimeException(e);
            }
        }

        public String toString() {
            return String.format("(%.6f, %.6f)", x, y);
        }

        public int hashCode() {
            return Double.hashCode(x) * 31 + Double.hashCode(y);
        }

        public boolean equals(Object obj) {
            Point2 other = (Point2) obj;
            return x == other.x && y == other.y;
        }

    }

    static class FastInput {
        private final InputStream is;
        private byte[] buf = new byte[1 << 13];
        private int bufLen;
        private int bufOffset;
        private int next;

        public FastInput(InputStream is) {
            this.is = is;
        }

        private int read() {
            while (bufLen == bufOffset) {
                bufOffset = 0;
                try {
                    bufLen = is.read(buf);
                } catch (IOException e) {
                    bufLen = -1;
                }
                if (bufLen == -1) {
                    return -1;
                }
            }
            return buf[bufOffset++];
        }

        public void skipBlank() {
            while (next >= 0 && next <= 32) {
                next = read();
            }
        }

        public int ri() {
            return readInt();
        }

        public int readInt() {
            int sign = 1;

            skipBlank();
            if (next == '+' || next == '-') {
                sign = next == '+' ? 1 : -1;
                next = read();
            }

            int val = 0;
            if (sign == 1) {
                while (next >= '0' && next <= '9') {
                    val = val * 10 + next - '0';
                    next = read();
                }
            } else {
                while (next >= '0' && next <= '9') {
                    val = val * 10 - next + '0';
                    next = read();
                }
            }

            return val;
        }

    }

    static class FastOutput implements AutoCloseable, Closeable, Appendable {
        private static final int THRESHOLD = 32 << 10;
        private final Writer os;
        private StringBuilder cache = new StringBuilder(THRESHOLD * 2);

        public FastOutput append(CharSequence csq) {
            cache.append(csq);
            return this;
        }

        public FastOutput append(CharSequence csq, int start, int end) {
            cache.append(csq, start, end);
            return this;
        }

        private void afterWrite() {
            if (cache.length() < THRESHOLD) {
                return;
            }
            flush();
        }

        public FastOutput(Writer os) {
            this.os = os;
        }

        public FastOutput(OutputStream os) {
            this(new OutputStreamWriter(os));
        }

        public FastOutput append(char c) {
            cache.append(c);
            afterWrite();
            return this;
        }

        public FastOutput append(int c) {
            cache.append(c);
            afterWrite();
            return this;
        }

        public FastOutput println(int c) {
            return append(c).println();
        }

        public FastOutput println() {
            return append('\n');
        }

        public FastOutput flush() {
            try {
//            boolean success = false;
//            if (stringBuilderValueField != null) {
//                try {
//                    char[] value = (char[]) stringBuilderValueField.get(cache);
//                    os.write(value, 0, cache.length());
//                    success = true;
//                } catch (Exception e) {
//                }
//            }
//            if (!success) {
                os.append(cache);
//            }
                os.flush();
                cache.setLength(0);
            } catch (IOException e) {
                throw new UncheckedIOException(e);
            }
            return this;
        }

        public void close() {
            flush();
            try {
                os.close();
            } catch (IOException e) {
                throw new UncheckedIOException(e);
            }
        }

        public String toString() {
            return cache.toString();
        }

    }
}

