import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.HashMap;
import java.util.Random;
import java.util.Map;
import java.io.OutputStreamWriter;
import java.io.OutputStream;
import java.util.Iterator;
import java.util.Set;
import java.io.IOException;
import java.io.UncheckedIOException;
import java.io.Closeable;
import java.util.Map.Entry;
import java.io.Writer;
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 << 27);
        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);
            TaskD solver = new TaskD();
            solver.solve(1, in, out);
            out.close();
        }
    }

    static class TaskD {
        public void solve(int testNumber, FastInput in, FastOutput out) {
            int m = in.readInt();
            int p = in.readInt();
            int l = in.readInt();
            int r = in.readInt();

            ExtLucas lucas = new ExtLucas(p, m);

            IntExtCRT crt = new IntExtCRT();

            for (Map.Entry<Integer, LongCombination> entry : lucas) {
                Modular mod = new Modular(entry.getKey());
                LongCombination comb = entry.getValue();
                long ans = 0;
                for (int n = 0; n <= m; n++) {
                    long a = comb.combination(n, DigitUtils.ceilDiv(n + l, 2));
                    long b = comb.combination(n, DigitUtils.floorDiv(n + r, 2) + 1);
                    long c = comb.combination(m, n);

                    long local = mod.subtract(a, b);
                    local = mod.mul(local, c);
                    ans = mod.plus(ans, local);
                }

                crt.add((int) ans, entry.getKey());
            }

            out.println(crt.getValue());
        }

    }

    static class MillerRabin {
        Modular modular;
        Power power;
        Random random = new Random();

        public boolean mr(int n, int s) {
            if (n <= 1) {
                return false;
            }
            if (n == 2) {
                return true;
            }
            if (n % 2 == 0) {
                return false;
            }
            int m = n - 1;
            while (m % 2 == 0) {
                m /= 2;
            }
            modular = new Modular(n);
            power = new Power(modular);
            for (int i = 0; i < s; i++) {
                int x = random.nextInt(n - 2) + 2;
                if (!mr0(x, n, m)) {
                    return false;
                }
            }
            return true;
        }

        private boolean mr0(int x, int n, int m) {
            return test(power.pow(x, m), m, n);
        }

        private boolean test(int y, int exp, int n) {
            int y2 = modular.mul(y, y);
            if (!(exp == n - 1 || test(y2, exp * 2, n))) {
                return false;
            }
            if (exp != n - 1 && y2 != 1) {
                return true;
            }
            if (y != 1 && y != n - 1) {
                return false;
            }
            return true;
        }

    }

    static class Modular {
        int m;

        public int getMod() {
            return m;
        }

        public Modular(int m) {
            this.m = m;
        }

        public Modular(long m) {
            this.m = (int) m;
            if (this.m != m) {
                throw new IllegalArgumentException();
            }
        }

        public Modular(double m) {
            this.m = (int) m;
            if (this.m != m) {
                throw new IllegalArgumentException();
            }
        }

        public int valueOf(int x) {
            x %= m;
            if (x < 0) {
                x += m;
            }
            return x;
        }

        public int valueOf(long x) {
            x %= m;
            if (x < 0) {
                x += m;
            }
            return (int) x;
        }

        public int mul(int x, int y) {
            return valueOf((long) x * y);
        }

        public int mul(long x, long y) {
            return valueOf(x * y);
        }

        public int plus(long x, long y) {
            return valueOf(x + y);
        }

        public int subtract(long x, long y) {
            return valueOf(x - y);
        }

        public String toString() {
            return "mod " + m;
        }

    }

    static class Factorial {
        int[] fact;
        int[] inv;
        Modular modular;

        public Modular getModular() {
            return modular;
        }

        public Factorial(int[] fact, int[] inv, InverseNumber in, int limit, Modular modular) {
            this.modular = modular;
            this.fact = fact;
            this.inv = inv;
            fact[0] = inv[0] = 1;
            for (int i = 1; i <= limit; i++) {
                fact[i] = modular.mul(fact[i - 1], i);
                inv[i] = modular.mul(inv[i - 1], in.inv[i]);
            }
        }

        public Factorial(int limit, Modular modular) {
            this(new int[limit + 1], new int[limit + 1], new InverseNumber(limit, modular), limit, modular);
        }

        public int fact(int n) {
            return fact[n];
        }

        public int invFact(int n) {
            return inv[n];
        }

    }

    static class PrimeCombination implements IntCombination {
        final Factorial factorial;
        final Modular modular;

        public PrimeCombination(Factorial factorial) {
            this.factorial = factorial;
            this.modular = factorial.getModular();
        }

        public PrimeCombination(int limit, Modular modular) {
            this(new Factorial(limit, modular));
        }

        public int combination(int m, int n) {
            if (n > m) {
                return 0;
            }
            return modular.mul(modular.mul(factorial.fact(m), factorial.invFact(n)), factorial.invFact(m - n));
        }

    }

    static class InverseNumber {
        int[] inv;

        public InverseNumber(int[] inv, int limit, Modular modular) {
            this.inv = inv;
            inv[1] = 1;
            int p = modular.getMod();
            for (int i = 2; i <= limit; i++) {
                int k = p / i;
                int r = p % i;
                inv[i] = modular.mul(-k, inv[r]);
            }
        }

        public InverseNumber(int limit, Modular modular) {
            this(new int[limit + 1], limit, modular);
        }

    }

    static class PollardRho {
        MillerRabin mr = new MillerRabin();
        Random random = new Random(1);

        public int findFactor(int n) {
            if (mr.mr(n, 5)) {
                return n;
            }
            while (true) {
                int f = rho(n);
                if (f != n) {
                    return f;
                }
            }
        }

        public Map<Integer, Integer> findAllFactors(int n) {
            Map<Integer, Integer> map = new HashMap();
            findAllFactors(map, n);
            return map;
        }

        private void findAllFactors(Map<Integer, Integer> map, int n) {
            if (n == 1) {
                return;
            }
            int f = findFactor(n);
            if (f == n) {
                Integer value = map.get(f);
                if (value == null) {
                    value = 1;
                }
                map.put(f, value * f);
                return;
            }
            findAllFactors(map, f);
            findAllFactors(map, n / f);
        }

        private int rho(int n) {
            if (n % 2 == 0) {
                return 2;
            }
            if (n % 3 == 0) {
                return 3;
            }
            int x = 0, y = x, t, q = 1, c = random.nextInt(n - 1) + 1;
            for (int k = 2; ; k <<= 1, y = x, q = 1) {
                for (int i = 1; i <= k; ++i) {
                    x = DigitUtils.mod((long) x * x + c, n);
                    q = DigitUtils.mod((long) q * Math.abs(x - y), n);
                    if ((i & 127) == 0) {
                        t = GCDs.gcd(q, n);
                        if (t > 1) {
                            return t;
                        }
                    }
                }
                if ((t = GCDs.gcd(q, n)) > 1) {
                    return t;
                }
            }
        }

    }

    static interface LongCombination {
        int combination(long n, long m);

    }

    static class FastInput {
        private final InputStream is;
        private byte[] buf = new byte[1 << 20];
        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 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 DigitUtils {
        private DigitUtils() {
        }

        public static int floorDiv(int a, int b) {
            return a < 0 ? -ceilDiv(-a, b) : a / b;
        }

        public static int ceilDiv(int a, int b) {
            if (a < 0) {
                return -floorDiv(-a, b);
            }
            int c = a / b;
            if (c * b < a) {
                return c + 1;
            }
            return c;
        }

        public static int mod(long x, int mod) {
            x %= mod;
            if (x < 0) {
                x += mod;
            }
            return (int) x;
        }

        public static int mod(int x, int mod) {
            x %= mod;
            if (x < 0) {
                x += mod;
            }
            return x;
        }

    }

    static class ExtGCD {
        private long x;
        private long y;
        private long g;

        public long getX() {
            return x;
        }

        public long extgcd(long a, long b) {
            if (a >= b) {
                g = extgcd0(a, b);
            } else {
                g = extgcd0(b, a);
                long tmp = x;
                x = y;
                y = tmp;
            }
            return g;
        }

        private long extgcd0(long a, long b) {
            if (b == 0) {
                x = 1;
                y = 0;
                return a;
            }
            long g = extgcd0(b, a % b);
            long n = x;
            long m = y;
            x = m;
            y = n - m * (a / b);
            return g;
        }

    }

    static class ExtLucas implements LongCombination, Iterable<Map.Entry<Integer, LongCombination>> {
        PollardRho pr = new PollardRho();
        Map<Integer, LongCombination> factorialMap = new HashMap();
        int p;

        public Iterator<Map.Entry<Integer, LongCombination>> iterator() {
            return factorialMap.entrySet().iterator();
        }

        public ExtLucas(int p, long m) {
            this.p = p;
            Map<Integer, Integer> factors = pr.findAllFactors(p);
            for (Map.Entry<Integer, Integer> entry : factors.entrySet()) {
                LongCombination combination;
                if (entry.getKey().equals(entry.getValue())) {
                    combination = new Lucas(new PrimeCombination((int) Math.min(m, entry.getKey()), new Modular(entry.getKey())),
                            entry.getKey());
                } else {
                    combination = new ExtLucas.ExtLucasFactorial(entry.getKey(), entry.getValue(), m);
                }
                factorialMap.put(entry.getValue(), combination);
            }
        }

        public int combination(long m, long n) {
            if (m < n) {
                return 0;
            }
            IntExtCRT extCRT = new IntExtCRT();
            for (Map.Entry<Integer, LongCombination> entry : factorialMap.entrySet()) {
                extCRT.add(entry.getValue().combination(m, n), entry.getKey());
            }

//        if (extCRT.r != BigCombination.combination(m, n).mod(BigInteger.valueOf(p)).intValue()) {
//            throw new RuntimeException();
//        }
            return extCRT.r;
        }

        public static class ExtLucasFactorial implements LongCombination {
            int exp;
            int fact;
            int p;
            int pc;
            Modular modular;
            Power power;
            ExtGCD extGCD = new ExtGCD();
            int[] g;

            public ExtLucasFactorial(int p, int pc, long m) {
                this.p = p;
                this.pc = pc;
                this.g = new int[(int) (Math.min(pc, m) + 1)];
                modular = new Modular(pc);
                power = new Power(modular);
                g[0] = 1;
                g[1] = 1;
                for (int i = 2; i < g.length; i++) {
                    if (i % p == 0) {
                        g[i] = g[i - 1];
                    } else {
                        g[i] = modular.mul(g[i - 1], i);
                    }
                }
            }

            private int fact(long m) {
                fact = 1;
                exp = 0;
                while (m > 1) {
                    exp += m / p;
                    if (m >= pc) {
                        fact = modular.mul(fact, power.pow(g[pc], m / pc));
                    }
                    fact = modular.mul(fact, g[(int) (m % pc)]);
                    m /= p;
                }
                return fact;
            }

            public int combination(long m, long n) {
                if (m < n) {
                    return 0;
                }
                int v = fact(m);
                int e = exp;
                extGCD.extgcd(fact(n), pc);
                v = modular.mul(v, modular.valueOf(extGCD.getX()));
                e -= exp;
                extGCD.extgcd(fact(m - n), pc);
                v = modular.mul(v, modular.valueOf(extGCD.getX()));
                e -= exp;
                v = modular.mul(v, power.pow(p, e));
                return v;
            }

        }

    }

    static class Lucas implements IntCombination, LongCombination {
        private final IntCombination primeCombination;
        private int mod;

        public Lucas(IntCombination primeCombination, int mod) {
            this.primeCombination = primeCombination;
            this.mod = mod;
        }

        public int combination(int m, int n) {
            return combination((long) m, (long) n);
        }

        public int combination(long m, long n) {
            if (n == 0) {
                return 1 % mod;
            }
            return (int) ((long) primeCombination.combination((int) (m % mod), (int) (n % mod)) *
                    combination(m / mod, n / mod) % mod);
        }

    }

    static class IntExtCRT {
        int r;
        int m;
        boolean valid = true;
        static final ExtGCD gcd = new ExtGCD();

        public IntExtCRT() {
            r = 0;
            m = 1;
        }

        public int getValue() {
            return r;
        }

        public boolean add(int r, int m) {
            int m1 = this.m;
            int x1 = this.r;
            int m2 = m;
            int x2 = DigitUtils.mod(r, m);
            int g = (int) gcd.extgcd(m1, m2);
            int a = (int) (gcd.getX() % m2);
            if ((x2 - x1) % g != 0) {
                return valid = false;
            }
            this.m = m1 / g * m2;
            this.r = DigitUtils.mod((long) a * ((x2 - x1) / g) % this.m * m1 % this.m + x1, this.m);
            return true;
        }

        public String toString() {
            return String.format("%d mod %d", r, m);
        }

    }

    static class Power {
        final Modular modular;

        public Power(Modular modular) {
            this.modular = modular;
        }

        public int pow(int x, long n) {
            if (n == 0) {
                return modular.valueOf(1);
            }
            long r = pow(x, n >> 1);
            r = modular.valueOf(r * r);
            if ((n & 1) == 1) {
                r = modular.valueOf(r * x);
            }
            return (int) r;
        }

        public int pow(int x, int n) {
            if (n == 0) {
                return modular.valueOf(1);
            }
            long r = pow(x, n >> 1);
            r = modular.valueOf(r * r);
            if ((n & 1) == 1) {
                r = modular.valueOf(r * x);
            }
            return (int) r;
        }

    }

    static interface IntCombination {
        int combination(int m, int n);

    }

    static class GCDs {
        private GCDs() {
        }

        public static int gcd(int a, int b) {
            return a >= b ? gcd0(a, b) : gcd0(b, a);
        }

        private static int gcd0(int a, int b) {
            return b == 0 ? a : gcd0(b, a % b);
        }

    }

    static class FastOutput implements AutoCloseable, Closeable, Appendable {
        private StringBuilder cache = new StringBuilder(10 << 20);
        private final Writer os;

        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;
        }

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

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

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

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

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

        public FastOutput println() {
            cache.append(System.lineSeparator());
            return this;
        }

        public FastOutput flush() {
            try {
                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();
        }

    }
}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.IOException;
import java.util.HashMap;
import java.util.Random;
import java.io.UncheckedIOException;
import java.io.Closeable;
import java.util.Map;
import java.io.Writer;
import java.util.Map.Entry;
import java.io.OutputStreamWriter;
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 << 27);
        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);
            TaskD solver = new TaskD();
            solver.solve(1, in, out);
            out.close();
        }
    }

    static class TaskD {
        public void solve(int testNumber, FastInput in, FastOutput out) {
            int m = in.readInt();
            int p = in.readInt();
            int l = in.readInt();
            int r = in.readInt();

            ExtLucas lucas = new ExtLucas(p, m);
            Modular mod = new Modular(p);

            long ans = 0;
            for (int n = 0; n <= m; n++) {
                long a = lucas.combination(n, DigitUtils.ceilDiv(n + l, 2));
                long b = lucas.combination(n, DigitUtils.floorDiv(n + r, 2) + 1);
                long c = lucas.combination(m, n);

                long local = mod.subtract(a, b);
                local = mod.mul(local, c);
                ans = mod.plus(ans, local);
            }

            out.println(ans);
        }

    }

    static class MillerRabin {
        Modular modular;
        Power power;
        Random random = new Random();

        public boolean mr(int n, int s) {
            if (n <= 1) {
                return false;
            }
            if (n == 2) {
                return true;
            }
            if (n % 2 == 0) {
                return false;
            }
            int m = n - 1;
            while (m % 2 == 0) {
                m /= 2;
            }
            modular = new Modular(n);
            power = new Power(modular);
            for (int i = 0; i < s; i++) {
                int x = random.nextInt(n - 2) + 2;
                if (!mr0(x, n, m)) {
                    return false;
                }
            }
            return true;
        }

        private boolean mr0(int x, int n, int m) {
            return test(power.pow(x, m), m, n);
        }

        private boolean test(int y, int exp, int n) {
            int y2 = modular.mul(y, y);
            if (!(exp == n - 1 || test(y2, exp * 2, n))) {
                return false;
            }
            if (exp != n - 1 && y2 != 1) {
                return true;
            }
            if (y != 1 && y != n - 1) {
                return false;
            }
            return true;
        }

    }

    static class Modular {
        int m;

        public Modular(int m) {
            this.m = m;
        }

        public Modular(long m) {
            this.m = (int) m;
            if (this.m != m) {
                throw new IllegalArgumentException();
            }
        }

        public Modular(double m) {
            this.m = (int) m;
            if (this.m != m) {
                throw new IllegalArgumentException();
            }
        }

        public int valueOf(int x) {
            x %= m;
            if (x < 0) {
                x += m;
            }
            return x;
        }

        public int valueOf(long x) {
            x %= m;
            if (x < 0) {
                x += m;
            }
            return (int) x;
        }

        public int mul(int x, int y) {
            return valueOf((long) x * y);
        }

        public int mul(long x, long y) {
            return valueOf(x * y);
        }

        public int plus(long x, long y) {
            return valueOf(x + y);
        }

        public int subtract(long x, long y) {
            return valueOf(x - y);
        }

        public String toString() {
            return "mod " + m;
        }

    }

    static class PollardRho {
        MillerRabin mr = new MillerRabin();
        Random random = new Random(1);

        public int findFactor(int n) {
            if (mr.mr(n, 5)) {
                return n;
            }
            while (true) {
                int f = rho(n);
                if (f != n) {
                    return f;
                }
            }
        }

        public Map<Integer, Integer> findAllFactors(int n) {
            Map<Integer, Integer> map = new HashMap();
            findAllFactors(map, n);
            return map;
        }

        private void findAllFactors(Map<Integer, Integer> map, int n) {
            if (n == 1) {
                return;
            }
            int f = findFactor(n);
            if (f == n) {
                Integer value = map.get(f);
                if (value == null) {
                    value = 1;
                }
                map.put(f, value * f);
                return;
            }
            findAllFactors(map, f);
            findAllFactors(map, n / f);
        }

        private int rho(int n) {
            if (n % 2 == 0) {
                return 2;
            }
            if (n % 3 == 0) {
                return 3;
            }
            int x = 0, y = x, t, q = 1, c = random.nextInt(n - 1) + 1;
            for (int k = 2; ; k <<= 1, y = x, q = 1) {
                for (int i = 1; i <= k; ++i) {
                    x = DigitUtils.mod((long) x * x + c, n);
                    q = DigitUtils.mod((long) q * Math.abs(x - y), n);
                    if ((i & 127) == 0) {
                        t = GCDs.gcd(q, n);
                        if (t > 1) {
                            return t;
                        }
                    }
                }
                if ((t = GCDs.gcd(q, n)) > 1) {
                    return t;
                }
            }
        }

    }

    static interface LongCombination {
    }

    static class FastInput {
        private final InputStream is;
        private byte[] buf = new byte[1 << 20];
        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 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 DigitUtils {
        private DigitUtils() {
        }

        public static int floorDiv(int a, int b) {
            return a < 0 ? -ceilDiv(-a, b) : a / b;
        }

        public static int ceilDiv(int a, int b) {
            if (a < 0) {
                return -floorDiv(-a, b);
            }
            int c = a / b;
            if (c * b < a) {
                return c + 1;
            }
            return c;
        }

        public static int mod(long x, int mod) {
            x %= mod;
            if (x < 0) {
                x += mod;
            }
            return (int) x;
        }

        public static int mod(int x, int mod) {
            x %= mod;
            if (x < 0) {
                x += mod;
            }
            return x;
        }

    }

    static class ExtGCD {
        private long x;
        private long y;
        private long g;

        public long getX() {
            return x;
        }

        public long extgcd(long a, long b) {
            if (a >= b) {
                g = extgcd0(a, b);
            } else {
                g = extgcd0(b, a);
                long tmp = x;
                x = y;
                y = tmp;
            }
            return g;
        }

        private long extgcd0(long a, long b) {
            if (b == 0) {
                x = 1;
                y = 0;
                return a;
            }
            long g = extgcd0(b, a % b);
            long n = x;
            long m = y;
            x = m;
            y = n - m * (a / b);
            return g;
        }

    }

    static class ExtLucas implements LongCombination {
        PollardRho pr = new PollardRho();
        Map<Integer, ExtLucas.ExtLucasFactorial> factorialMap = new HashMap();
        int p;

        public ExtLucas(int p, long m) {
            this.p = p;
            Map<Integer, Integer> factors = pr.findAllFactors(p);
            for (Map.Entry<Integer, Integer> entry : factors.entrySet()) {
                factorialMap.put(entry.getValue(),
                        new ExtLucas.ExtLucasFactorial(entry.getKey(), entry.getValue(), m));
            }
        }

        public int combination(long m, long n) {
            if (m < n) {
                return 0;
            }
            IntExtCRT extCRT = new IntExtCRT();
            for (Map.Entry<Integer, ExtLucas.ExtLucasFactorial> entry : factorialMap.entrySet()) {
                extCRT.add(entry.getValue().combination(m, n), entry.getKey());
            }

//        if (extCRT.r != BigCombination.combination(m, n).mod(BigInteger.valueOf(p)).intValue()) {
//            throw new RuntimeException();
//        }
            return extCRT.r;
        }

        private static class ExtLucasFactorial implements LongCombination {
            int exp;
            int fact;
            int p;
            int pc;
            Modular modular;
            Power power;
            ExtGCD extGCD = new ExtGCD();
            int[] g;

            public ExtLucasFactorial(int p, int pc, long m) {
                this.p = p;
                this.pc = pc;
                this.g = new int[(int) (Math.min(pc, m) + 1)];
                modular = new Modular(pc);
                power = new Power(modular);
                g[0] = 1;
                g[1] = 1;
                for (int i = 2; i < g.length; i++) {
                    if (i % p == 0) {
                        g[i] = g[i - 1];
                    } else {
                        g[i] = modular.mul(g[i - 1], i);
                    }
                }
            }

            private int fact(long m) {
                fact = 1;
                exp = 0;
                while (m > 1) {
                    exp += m / p;
                    if (m >= pc) {
                        fact = modular.mul(fact, power.pow(g[pc], m / pc));
                    }
                    fact = modular.mul(fact, g[(int) (m % pc)]);
                    m /= p;
                }
                return fact;
            }

            public int combination(long m, long n) {
                if (m < n) {
                    return 0;
                }
                int v = fact(m);
                int e = exp;
                extGCD.extgcd(fact(n), pc);
                v = modular.mul(v, modular.valueOf(extGCD.getX()));
                e -= exp;
                extGCD.extgcd(fact(m - n), pc);
                v = modular.mul(v, modular.valueOf(extGCD.getX()));
                e -= exp;
                v = modular.mul(v, power.pow(p, e));
                return v;
            }

        }

    }

    static class IntExtCRT {
        int r;
        int m;
        boolean valid = true;
        static final ExtGCD gcd = new ExtGCD();

        public IntExtCRT() {
            r = 0;
            m = 1;
        }

        public boolean add(int r, int m) {
            int m1 = this.m;
            int x1 = this.r;
            int m2 = m;
            int x2 = DigitUtils.mod(r, m);
            int g = (int) gcd.extgcd(m1, m2);
            int a = (int) (gcd.getX() % m2);
            if ((x2 - x1) % g != 0) {
                return valid = false;
            }
            this.m = m1 / g * m2;
            this.r = DigitUtils.mod((long) a * ((x2 - x1) / g) % this.m * m1 % this.m + x1, this.m);
            return true;
        }

        public String toString() {
            return String.format("%d mod %d", r, m);
        }

    }

    static class Power {
        final Modular modular;

        public Power(Modular modular) {
            this.modular = modular;
        }

        public int pow(int x, long n) {
            if (n == 0) {
                return modular.valueOf(1);
            }
            long r = pow(x, n >> 1);
            r = modular.valueOf(r * r);
            if ((n & 1) == 1) {
                r = modular.valueOf(r * x);
            }
            return (int) r;
        }

        public int pow(int x, int n) {
            if (n == 0) {
                return modular.valueOf(1);
            }
            long r = pow(x, n >> 1);
            r = modular.valueOf(r * r);
            if ((n & 1) == 1) {
                r = modular.valueOf(r * x);
            }
            return (int) r;
        }

    }

    static class GCDs {
        private GCDs() {
        }

        public static int gcd(int a, int b) {
            return a >= b ? gcd0(a, b) : gcd0(b, a);
        }

        private static int gcd0(int a, int b) {
            return b == 0 ? a : gcd0(b, a % b);
        }

    }

    static class FastOutput implements AutoCloseable, Closeable, Appendable {
        private StringBuilder cache = new StringBuilder(10 << 20);
        private final Writer os;

        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;
        }

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

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

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

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

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

        public FastOutput println() {
            cache.append(System.lineSeparator());
            return this;
        }

        public FastOutput flush() {
            try {
                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();
        }

    }
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

/**
 *
 * @author tino chagua
 */
public class A {

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] cad = br.readLine().split(" ");
        int n = Integer.valueOf(cad[0]);
        int c = Integer.valueOf(cad[1]);
        int[] price = new int[n];
        String[] str = br.readLine().split(" ");
        for (int i = 0; i < n - 1; i++) {
            price[i] = Integer.valueOf(str[i]) - Integer.valueOf(str[i + 1]);
        }
        Arrays.sort(price);
        System.out.println(price[n-1]-c);
        //show(price);
    }

    static void  show(int[] a) {
        for (int i = 0; i < a.length; i++) {
            System.out.print(a[i] + " ");
        }
        System.out.println();
    }
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class bearhoney {
	public static void main(String args[])throws IOException
	{
		BufferedReader ds = new BufferedReader(new InputStreamReader(System.in));
		PrintWriter out = new PrintWriter(System.out);

		StringTokenizer s = new StringTokenizer(ds.readLine());
		int  n  =  Integer.parseInt(s.nextToken());
		int c =  Integer.parseInt(s.nextToken());
		int a[] = new int [n];
		s = new StringTokenizer(ds.readLine());
		int max =  0 , x = 0 ;
		a[0] =  Integer.parseInt(s.nextToken());
		for( int  i = 1 ; i < n ; i++)
		{	int dif = 0;
			a[i] =  Integer.parseInt(s.nextToken());

				dif= a[i-1] - a[i];
				if(max<dif)
					{
						max = dif;
						x = i-1 ;
					}

		}
		System.out.println(max-c);
	}

}


import java.util.Scanner;
import java.util.ArrayList;

public class Practica_2 {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int dias = in.nextInt();
        int kg = in.nextInt();
        String c = "";
        for (int i = 0; i < dias; i++) {
            int a = in.nextInt();
            c += a + " ";
        }
        String d = c.trim();
        ArrayList<Integer> abc = new ArrayList<Integer>();
        String array[] = d.split(" +");
        int pos = 0;
        while (pos < array.length - 1) {
            if (Integer.parseInt(array[pos]) > Integer.parseInt(array[pos + 1])) {
                int resta = Integer.parseInt(array[pos]) - Integer.parseInt(array[pos + 1]) - kg;
                abc.add(resta);
            }
            pos++;
        }
        if (abc.size() == 0) {
            System.out.println(0);
        } else {
            int mayor = abc.get(0);
            for (int i = 0; i < abc.size(); i++) {
                if (mayor < abc.get(i)) {
                    mayor = abc.get(i);
                }
            }
            System.out.println(mayor);
        }
    }
}


import java.util.*;
public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
    Scanner sc=new Scanner(System.in);
    int i,n,c,x=0,p=0,j=0;
    n=sc.nextInt();
    c=sc.nextInt();
    int a[] =new int[n];
    for(i=0;i<n;i++)
    {
        a[i]=sc.nextInt();
    }
    for(i=0;i<n-1;i++)
    {
        if(a[i]>a[i+1]  )
        {

           p=a[i]-a[i+1];

            if(p>=x)
            {

                x=p;
                j=i;
            }
        }
     }
       System.out.println(x-c);

    }
}


import java.io.IOException;

public class A102 {

    public static void main(String[] args) throws IOException {
        java.io.BufferedReader r = new java.io.BufferedReader(
                new java.io.InputStreamReader(System.in));
        String[] rr = r.readLine().split(" ");
        String[] c = r.readLine().split(" ");
        String[] d = r.readLine().split(" ");

        for (int i = 1; i < 11; i++)
            for (int j = 1; j < 10; j++)
                for (int k = 1; k < 10; k++)
                    for (int l = 1; l < 10; l++) {
                        if ((i + j == Integer.parseInt(rr[0]))
                                && (k + l == Integer.parseInt(rr[1]))
                                && (i + k == Integer.parseInt(c[0]))
                                && (j + l == Integer.parseInt(c[1]))
                                && (i + l == Integer.parseInt(d[0]))
                                && (j + k == Integer.parseInt(d[1]))
                                && (i != j)
                                && (i != k)
                                && (i != l)
                                && (j != k)
                                && (j != l)
                                && (k != l)) {
                            System.out.println(i + " " + j);
                            System.out.println(k + " " + l);
                            return;
                        }
                    }

        System.out.println(-1);

    }
}


import java.io.*;
import java.util.*;

public class Main {
	public static void main(String[] args) throws Exception {
		PrintWriter pr = new PrintWriter(System.out, true);
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		// Scanner s = new Scanner(System.in);
		StringTokenizer st = new StringTokenizer(in.readLine());
		int r1 = Integer.parseInt(st.nextToken());
		int r2 = Integer.parseInt(st.nextToken());
		st = new StringTokenizer(in.readLine());
		int c1 = Integer.parseInt(st.nextToken());
		int c2 = Integer.parseInt(st.nextToken());
		st = new StringTokenizer(in.readLine());
		int d1 = Integer.parseInt(st.nextToken());
		int d2 = Integer.parseInt(st.nextToken());
		for(int i = 1;i <= 9;i++) {
			for(int j = 1;j <= 9;j++) {
				for(int k = 1;k <= 9;k++) {
					for(int m = 1;m <= m;i++) {
						if((i == j) || (i == k) || (i == m) || (j == k) || (j == m) || (k == m)) continue;
						if(i+j == r1 && k+m == r2 && i+k == c1 && m+j == c2 && i+m == d1 && k+j == d2) {
							pr.println(i+" "+j);
							pr.println(k+" "+m);
							return;
						}
					}
				}
			}

		}
	}
}


import java.util.*;

    public class Main {

        public static void main(String[] args) {
            Scanner input=new Scanner(System.in);
          int min1,r1,r2,c1,c2,d1,d2, a1=0,a2=0,a3=0,a4=0;
          r1=input.nextInt();
          r2=input.nextInt();
          c1=input.nextInt();
          c2=input.nextInt();
          d1=input.nextInt();
          d2=input.nextInt();
        min1=Math.min(d1, c1);
        min1=Math.min(min1, r1);
            Set<Integer>s=new TreeSet<>();
        if(min1<10){
            a1=min1-1;
        }else{a1=9;}

        a4=d1-a1;

        a2=c2-a4;
        a3=r2-a4;
        boolean f=false;
        while(a1>0){
             a4=d1-a1;

        a2=c2-a4;
        a3=r2-a4;
        s.clear();

            s.add(a1);s.add(a2);s.add(a3);s.add(a4);
        if(a1+a4==d1&&a1+a2==r1&&a1+a3==c1&&a2+a3==d2&&a2+a4==c2&&a3+a4==r2&&s.size()==4){
            if(a1<10&&a2<10&&a3<10&&a4<10)
            {
            f=true;

            break;}
        }else{
        a1--;
        }
        }

        if(f)
                System.out.println(a1+" "+a2+"\n"+a3+" "+a4);
        else
                System.out.println(-1);
        }

    }


import java.util.Scanner;

public class helpVasilisa {
    public static void main(String[] args){
        Scanner input=new Scanner(System.in);
        int r1=input.nextInt();
        int r2=input.nextInt();
        int c1=input.nextInt();
        int c2=input.nextInt();
        int d1=input.nextInt();
        int d2=input.nextInt();
        int rlc,ruc,luc,llc;
        if(d1<10){
            rlc=d1-1;
            luc=d1-rlc;
        }else{
            rlc=9;
            luc=d1-rlc;
        }
        while(true){
            llc=c1-luc;
            if(llc>=10||(llc+rlc)!=r2){
                rlc--;
                luc++;
                continue;
            }
            if(rlc<=0||luc>10){
                System.out.println("-1");
                return;
            }
            break;
        }
        ruc=c2-rlc;
        if(ruc>10||ruc<=0||ruc==luc||ruc==rlc||rlc==luc||rlc==llc||llc==luc){
            System.out.println(-1);
        }else{
            System.out.println(luc+" "+ruc);
            System.out.println(llc+" "+rlc);
        }
    }
}


import java.util.*;
public class Number25
{
public static void main(String[] args)
{
Scanner sc = new Scanner(System.in);
long n = sc.nextLong();
long a = 1;
for(int i = 0;i < n;i++)
{
      a *= 5;
}
String s = String.valueOf(a);
System.out.println(s.substring(s.length() - 2));
}
}


import java.util.*;
public class AgainTwentyFive {
    public static void main(String[] args) {
        Scanner in= new Scanner (System.in);
        String n= in.next();
        Long N= new Long (Long.valueOf(n));
        Long z= new Long (0);
        Long l= N-1;
        Long power= new Long(5);
        for(Long i=z; i<=l; i++) {
            power*= 5;
        }
        String u=""+ power;
        String t=""+ u.charAt(u.length()-2)+u.charAt(u.length()-1);
        System.out.println(t);
    }
}


import java.util.Scanner;

public class AgainTwentyFive {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        double n = in.nextDouble();
        double total = 5.0;
        for (int i = 0; i < n; i++) {
            total *= 5;
            }
        System.out.println((int)total % 100);
    }
}


import java.io.*;
import java.lang.*;
import java.util.*;
import java.math.*;

public class Test{
  public static void main(String args[]){

    Scanner sc = new Scanner(System.in);

    String str = sc.next();

    BigInteger big1 = new BigInteger(str);
    BigInteger big2 = new BigInteger("5");
    BigInteger big3 = new BigInteger("1");
    BigInteger big4 = new BigInteger("5");
    BigInteger big5 = new BigInteger("1");

    while((big1.compareTo(big3)==1)){

      big2 = big2.multiply(big4);

       big1 = big1.subtract(big5);
    }

    String st = big2.toString();

    System.out.println("25");
  }
}


import java.util.Scanner;
public class PetyaA
{
 public static void main(String[] args){

  Scanner in = new Scanner(System.in);
  String num = in.nextLine();
   if((Long.toString(Long.MAX_VALUE)).compareTo(num)>0 || (Long.toString(Long.MIN_VALUE)).compareTo(num)>0){
    long numInt= Long.parseLong(num);
       if(numInt>=Byte.MIN_VALUE && numInt<=Byte.MAX_VALUE){
          System.out.println("byte");
        }else if(numInt>=Short.MIN_VALUE && numInt<=Short.MAX_VALUE){
         System.out.println("short");
        }else if(numInt>=Integer.MIN_VALUE && numInt<=Integer.MAX_VALUE){
         System.out.println("int");
        }else{
            if (numInt>=Long.MIN_VALUE && numInt<=Long.MAX_VALUE){
             System.out.println("long");
           }
          }
     }else{
      System.out.println("BigInteger");
    }

 }
}


import java.util.*;
public class Petya {

    public static void main(String[] args) {
       Scanner s=new Scanner(System.in);
       long n=s.nextLong();

       try{

       if(n>=-128&&n<=127)
           System.out.print("byte");
       else if(n>=-32768 && n<=32767)
           System.out.print("short");
       else if (n>=-2147483648 && n<=2147483647)
           System.out.println("int");
       else
           System.out.println("long");
           }
    catch(Exception ex){
        System.out.println("BigInteger");
    }
}
}


package test;

import java.util.Scanner;
import java.math.BigInteger;

public class Test {

    public static void main(String[] args) {
        BigInteger x,y,z,a,b;
        Scanner k = new Scanner(System.in);
        x = k.nextBigInteger();
        y=new BigInteger ("127");
        z=new BigInteger ("32767");
        a=new BigInteger ("2147483647");
        b=new BigInteger ("9223372036854775807");
        if (x.compareTo(y) == 1 || x.compareTo(y) == 0)
            System.out.println("byte");
         else if (x.compareTo(z) == 1  || x.compareTo(z) == 0)
            System.out.println("short");
         else if (x.compareTo(a) == 1 || x.compareTo(a)==0 )
            System.out.println("int");
        else if (x.compareTo(b) == 1 || x.compareTo(b) == 0)
            System.out.println("long");
        else
            System.out.println("BigInteger");
    }
}
//Okasha


import java.util.Scanner;
public class Main {
    public static void main(String[] args){
        Scanner sc= new Scanner(System.in);
        String line;

        while(sc.hasNextLine()){

        double a = sc.nextDouble();

        if(a<0){
            a+=1;
        }
        a= Math.abs(a);
           if(a<Byte.MAX_VALUE+1){
               System.out.println("byte");
                      }  else if(a<Short.MAX_VALUE+1){
               System.out.println("short");
        }else if(a<Integer.MAX_VALUE+1){
            System.out.println("int");
        } else if(a<Long.MAX_VALUE+1){
            System.out.println("long");
        } else {
            System.out.println("BigInteger");
        }

    }}}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;

public class ObsessionWithRobots {

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String t = br.readLine().trim();
        int len = t.length();
        int x = len;
        int y = len;
        int[][] board = new int[2 * len][2 * len];
        PrintWriter out = new PrintWriter(System.out);
        boolean bug = false;
        for (int i = 0; i < len; i++) {
            board[x][y] = 1;
            switch (t.charAt(i)) {
            case 'R':
                x++;
                break;
            case 'L':
                x--;
                break;
            case 'U':
                y--;
                break;
            case 'D':
                y++;
            }
            if (board[x][y] == 1) {
                out.println("BUG");
                bug = true;
                break;
            }
        }
        if (!bug) {
            out.println("OK");
        }
        out.close();
    }

}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Task8B {

	private static int[][] stepL = { { -1, 0 }, { 0, -1 }, { 0, +1 } };
	private static int[][] stepR = { { 1, 0 }, { 0, -1 }, { 0, +1 } };
	private static int[][] stepU = { { -1, 0 }, { 1, 0 }, { 0, +1 } };
	private static int[][] stepD = { { -1, 0 }, { 1, 0 }, { 0, -1 } };

	public static void main(String[] args) {
		char[] path;
		try {
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			path = br.readLine().toCharArray();
		} catch (IOException e) {
			System.out.println(e);
			return;
		}
		boolean[][] map = new boolean[path.length * 2 + 2][path.length * 2 + 2];
		int x = path.length + 1;
		int y = x;
		int[][] step;
		int j;
		for (int i = 0; i < path.length; i++) {
			map[x][y] = true;
			switch (path[i]) {
			case 'L':
				x--;
				step = stepL;
				break;
			case 'R':
				x++;
				step = stepR;
				break;
			case 'U':
				y++;
				step = stepU;
				break;
			case 'D':
				y--;
				step = stepD;
				break;
			default:
				System.out.println("Unknown step '" + path[i] + "'");
				return;
			}
			for (j = 0; j < 3; j++) {
				if (map[x + step[j][0]][y + step[j][1]]) {
					System.out.println("BUG");
					return;
				}
			}
		}
		System.out.println("OK");
	}
}


import java.util.*;
import java.io.*;

public class Main implements Runnable {

	public void solve() throws IOException {
		//it the robot moves to an already visited place. Then there is a BUG
                // + if ok  check it is shortest or not.
                int x = 0;
                int y = 0;
                int minx = 0;
                int maxx = 0;
                int miny = 0;
                int maxy = 0;

                String s = nextToken();
                for(char c : s.toCharArray()){
                        if(c == 'L')x--;
                        if(c == 'R')x++;
                        if(c == 'U')y++;
                        if(c == 'D')y--;
                        minx = Math.min(minx, x);
                        miny = Math.min(miny, y);
                        maxx = Math.max(maxx, x);
                        maxy = Math.max(maxy, y);
                }

                boolean[][] map = new boolean[maxy - miny + 1][maxx - minx + 1];
                int sx = Math.abs(minx);
                int sy = Math.abs(miny);
                int startx = sx;
                int starty = sy;
                int endx = -1;
                int endy = -1;

                boolean ok = true;
                map[sy][sx] = true;
                for(char c : s.toCharArray()){
                        if(c == 'L')sx--;
                        if(c == 'R')sx++;
                        if(c == 'U')sy++;
                        if(c == 'D')sy--;
                        endx = sx;
                        endy = sy;
                        if(map[sy][sx]) ok = false;
                        map[sy][sx] = true;
                }

                if(!ok) System.out.println("BUG");
                else{
                        int shortestPathLength = doit(startx, starty, endx, endy, map);
                        if(shortestPathLength == s.length()){
                                System.out.println("OK");
                        }
                        else
                                System.out.println("BUG");
                }

	}

        int[] dx = {0, 0, 1, -1};
        int[] dy = {1, -1, 0, 0};

	private int doit(int sx, int sy, int ex, int ey, boolean[][] map){
                //run bfs
                int R = map.length;
                int C = map[0].length;

                int[][] d = new int[map.length][map[0].length];
                for(int i = 0; i < d.length; i++) Arrays.fill(d[i], -1);

                d[sy][sx] = 0;
                Queue<Integer> q = new LinkedList<>();
                q.add(sx); q.add(sy);

                while(!q.isEmpty()){
                        int x = q.poll();
                        int y = q.poll();
                        for(int k = 0; k < 4; k++){
                                int nx = x + dx[k];
                                int ny = y + dy[k];
                                if(nx >= 0 && ny >= 0 && nx < C && ny < R && map[ny][nx] && d[ny][nx] == - 1){
                                        d[ny][nx] = d[y][x] + 1;
                                        q.add(nx);
                                        q.add(ny);
                                }
                        }
                }

                return d[ex][ey];
        }

	//-----------------------------------------------------------
	public static void main(String[] args) {
		new Main().run();
	}

        public void print1Int(int[] a){
                for(int i = 0; i < a.length; i++)
                        System.out.print(a[i] + " ");
                System.out.println();
        }

        public void print2Int(int[][] a){
                for(int i = 0; i < a.length; i++){
                        for(int j = 0; j < a[0].length; j++){
                                System.out.print(a[i][j] + " ");
                        }
                        System.out.println();
                }
        }

	public void run() {
		try {
			in = new BufferedReader(new InputStreamReader(System.in));
			tok = null;
			solve();
			in.close();
		} catch (IOException e) {
			System.exit(0);
		}
	}

	public String nextToken() throws IOException {
		while (tok == null || !tok.hasMoreTokens()) {
			tok = new StringTokenizer(in.readLine());
		}
		return tok.nextToken();
	}

	public int nextInt() throws IOException {
		return Integer.parseInt(nextToken());
	}

	public long nextLong() throws IOException {
		return Long.parseLong(nextToken());
	}

	public double nextDouble() throws IOException {
		return Double.parseDouble(nextToken());
	}

	BufferedReader in;
	StringTokenizer tok;
}


import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.*;
public class A {
	InputStream is;
	PrintWriter out;
	String INPUT = "";

	void solve()
	{
	   //out.println((Integer.toBinaryString(ni())).length());
	   String s = ns();
	   int a[][] = new int[10001][10001];
	   int x = 100, y = 100;
	   String ans = "OK";
	   a[x][y] = 1;
	   for(int i=0;i<s.length();i++){
	       char ch = s.charAt(i);
	       if(ch=='R') x++;
	       else if(ch=='U') y++;
	       else if(ch=='D') y--;
	       else x--;
	       if(a[x][y]==1) ans = "BUG";
	       a[x][y] = 1;
	   }
	   out.println(ans);
	}

	void run() throws Exception
	{
		is = INPUT.isEmpty() ? System.in : new ByteArrayInputStream(INPUT.getBytes());
		out = new PrintWriter(System.out);

		long s = System.currentTimeMillis();
		solve();
		out.flush();
		if(!INPUT.isEmpty())tr(System.currentTimeMillis()-s+"ms");
	}

	public static void main(String[] args) throws Exception { new A().run(); }

	private byte[] inbuf = new byte[1024];
	public int lenbuf = 0, ptrbuf = 0;

	private int readByte()
	{
		if(lenbuf == -1)throw new InputMismatchException();
		if(ptrbuf >= lenbuf){
			ptrbuf = 0;
			try { lenbuf = is.read(inbuf); } catch (IOException e) { throw new InputMismatchException(); }
			if(lenbuf <= 0)return -1;
		}
		return inbuf[ptrbuf++];
	}

	private boolean isSpaceChar(int c) { return !(c >= 33 && c <= 126); }
	private int skip() { int b; while((b = readByte()) != -1 && isSpaceChar(b)); return b; }

	private double nd() { return Double.parseDouble(ns()); }
	private char nc() { return (char)skip(); }

	private String ns()
	{
		int b = skip();
		StringBuilder sb = new StringBuilder();
		while(!(isSpaceChar(b))){ // when nextLine, (isSpaceChar(b) && b != ' ')
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	private char[] ns(int n)
	{
		char[] buf = new char[n];
		int b = skip(), p = 0;
		while(p < n && !(isSpaceChar(b))){
			buf[p++] = (char)b;
			b = readByte();
		}
		return n == p ? buf : Arrays.copyOf(buf, p);
	}

	private char[][] nm(int n, int m)
	{
		char[][] map = new char[n][];
		for(int i = 0;i < n;i++)map[i] = ns(m);
		return map;
	}

	private int[] na(int n)
	{
		int[] a = new int[n];
		for(int i = 0;i < n;i++)a[i] = ni();
		return a;
	}

	private int ni()
	{
		int num = 0, b;
		boolean minus = false;
		while((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'));
		if(b == '-'){
			minus = true;
			b = readByte();
		}

		while(true){
			if(b >= '0' && b <= '9'){
				num = num * 10 + (b - '0');
			}else{
				return minus ? -num : num;
			}
			b = readByte();
		}
	}

	private long nl()
	{
		long num = 0;
		int b;
		boolean minus = false;
		while((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'));
		if(b == '-'){
			minus = true;
			b = readByte();
		}

		while(true){
			if(b >= '0' && b <= '9'){
				num = num * 10 + (b - '0');
			}else{
				return minus ? -num : num;
			}
			b = readByte();
		}
	}

	private static void tr(Object... o) { System.out.println(Arrays.deepToString(o)); }
}


import java.io.*;
import java.util.*;

import java.math.*;

public class Main {

	static class FastReader
    {
        BufferedReader br;
        StringTokenizer st;

        public FastReader()
        {
            br = new BufferedReader(new
                     InputStreamReader(System.in));
        }

        String next()
        {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException  e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt()
        {
            return Integer.parseInt(next());
        }

        long nextLong()
        {
            return Long.parseLong(next());
        }

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

        String nextLine()
        {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }

	static int n, ans1 = 1, ans2 = 1;
	static Integer[] arr;
	static int[] occur;

	public static void main(String args[]) throws Exception {
		FastReader cin = new FastReader();

		n = cin.nextInt();
		arr = new Integer[n];
		occur = new int[100005];

		for (int i = 0; i < n; i++) {
			arr[i] = cin.nextInt();
			occur[arr[i]] += 1;
		}
		Arrays.parallelSort(arr);

		ans2 = arr[n-1];
		for (int i = n-2; i >= 0; i--) {
			if (ans2 % arr[i] != 0 || arr[i] == ans2 || occur[arr[i]] == 2) {
				ans1 = arr[i];
				break;
			}
		}

		System.out.println(ans1 + " " + ans2);
	}
}


import java.util.*;
import java.math.*;

public class today
{
	public static void main(String ag[])
	{
		Scanner sc=new Scanner(System.in);
		int n,t,i,j,k;
		j=0;
int a=0;
int b=0;

		n=sc.nextInt();

		int arr[]=new int[n];
		for(i=0;i<n;i++)
		arr[i]=sc.nextInt();
		Arrays.sort(arr);
k=arr[n-1];
int count=0;

ArrayList<Integer> al=new ArrayList<Integer>();
if(n==2||arr[n-1]==arr[n-2])
System.out.println(arr[n-1]+" "+arr[n-2]);
else
{

	t=1;
				for(i=2;i<=n-3;)
				{
					if(i<=n-3&&arr[i]==arr[i+1]&&(i+1<=n-2))
					{
						al.add(arr[i]);
						i=i+2;
					}
					else
					i++;
				}
				if(al.size()>0){
				Collections.sort(al); t=al.get(al.size()-1);}
				for(i=2;i<=n-2;i++)
				{
					if(k%arr[i]!=0&&arr[i]>t)
					{
					al.add(arr[i]);
					}
				}

				if(al.size()>0)
				{
				Collections.sort(al);
				System.out.println(k+" "+al.get(al.size()-1));
				}
				else
				{
				System.out.println(k+" "+1);
				}

}

	}
}

class Tcomp implements Comparator<Node>
{

    @Override
    public int compare(Node e1, Node e2) {
        if(e1.getValue() > e2.getValue()){
            return 1;
        } else {
            return -1;
        }
    }
}

class Node
{
	int key,value;
	Node(int key,int value)
	{
		this.key=key;
		this.value=value;
	}

	public int getKey()
	{
		return this.key;
	}
	public int getValue()
	{
		return this.value;
	}
	public void setValue(int k)
	{
		this.value=k;
	}
}


//package com.company;
import java.util.*;
public class Main {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n=in.nextInt();
        int A[]=new int[n];
        for(int i=0;i<n;i++)
        {
            A[i]=in.nextInt();
        }
        Arrays.sort(A);
        int gcdi=0;
        for(int i=0;i<n-1;i++)
        {
            if(A[i]==A[i+1])
            {
                gcdi=i;
            }
        }

        if(A[n-1]==A[n-2])
        {
            System.out.println(A[n-1]+" "+A[n-1]);
        }
        else
        {
            System.out.print(A[n-1]+" ");
            int tmp=0;
            for(int j=n-2;j>=gcdi;j--)
            {
                if(A[n-1]%A[j]!=0)
                {
                    System.out.print(A[j]);
                    tmp++;
                    break;
                }
            }
            if(tmp==0)
            {
                System.out.print(A[gcdi]);
            }
        }
    }
}


import java.util.*;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class ar {

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

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

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
static boolean[] seen;
static long[] arr;
 public static void main(String[] args) throws java.lang.Exception {
        FastReader scn = new FastReader();
     int n=scn.nextInt();

    List<Integer> list = new ArrayList<>();
    for(int i=0;i<n;i++){
        list.add(scn.nextInt());
    }
    if(n==2){
        System.out.print(1+" "+1+"\n");
        return;
    }
    Collections.sort(list);
    int fnum=list.get(n-1);
if(fnum==list.get(n-2)){
    System.out.print(fnum+" "+fnum+"\n");
    return;
}
for(int i=1;i<=fnum;i++){
    for(int j=0;j<list.size();j++){
        if(fnum%i==0 && list.get(j)==i){
            list.remove(j);
            break;
        }
    }
}
System.out.print(fnum+" "+list.get(list.size()-1)+"\n");

    }

}


/* package whatever; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
public class Ideone
{
	public static void main (String[] args) throws java.lang.Exception
	{
		 Scanner sc = new Scanner(System.in);
        int t = sc.nextInt();
        System.out.println("t value:"+t);
        for (int x = 0; x < t; x++) {
            int n=sc.nextInt();
             System.out.println("n value:"+n);
            int k=sc.nextInt();
             System.out.println("k value:"+k);
            int arr[]= new int[n];
            for(int j=0;j<n;j++){
            	System.out.println("jjnck");
            arr[j]=sc.nextInt();
             System.out.println("array value:"+arr[j]);
            }
            System.out.println(FindCriminal(n,k,arr));
        }
	}
	static int FindCriminal(int n,int index,int array[]){
		int count=0;
		for(int i=0;i<array.length;i++){

          if((index-i)>=0 && (index+i)<array.length) {

                 if (array[index - i] == 1 && array[index + i] == 1) {
                     if (i == 0) {
                         count++;
                     } else {
                         count = count + 2;
                     }
                 }
             } else if((index-i)>=0){
              if(array[index-i] == 1){
                  count++;
              }
          } else if((index+i)<array.length){
              if(array[index+i] == 1){
                  count++;
              }
          }

        }
        return count;
	}
}


import java.util.*;
public class Bear_finding_Criminals {

	public static int Bear(int[] nums , int n,int a)
	{
		int j=a-1,k=a+1,count=0;
		if(nums[a]==1)
		{
			count=1;
		}
		while(j>=0 && k<n)
		{
			if(nums[a]==1)
			{

				if(nums[a]-nums[j]==0 && nums[a]-nums[k]==0)
				{
					count+=2;
				}
			}else
			{
				if(nums[a]-nums[j]==0 && nums[a]-nums[k]==0)
				{
					continue;
				}
				else
					count++;
			}
			j--;
			k++;
		}

		while(j>=0)
		{
			if(nums[j]==1)
			{
				count++;
			}
			j--;
		}
		while(k<n)
		{
			if(nums[k]==1)
			{
				count++;
			}
			k++;
		}
		//System.out.println(j+"    "+k);
		return count;
	}

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int a = scan.nextInt();
		int[] nums = new int[n];
		for(int i=0;i<n;i++)
		{
			nums[i] = scan.nextInt();
		}
		System.out.println(Bear(nums,n,a-1));
	}

}


import java.util.*;
public class X{
public static void main(String... args){
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int a = sc.nextInt();
int[] t = new int[n];
for (int i=0; i<n; i++){
  t[i] = sc.nextInt();
}
int total = 0;
if (t[a]==1) total++;
int l = a-1;
int r = a+1;
while (l>=0 || r<n){
  if (l==-1 && t[r]==1) total++;
  if (r==n && t[l]==1) total++;
  if (l>=0 && r<n && t[r]==1 && t[l]==1) total+=2;
}
System.out.println(total);
}
}


import java.util.Scanner;

public class BearAndFindingCriminals
{
	public static void solution(int[] a1,int m1,int m2)
	{
		int res=0;
		int left=m2;
		int right=m2;

		for(int i=0;i<m1+1;i++)
		{
			res+=a1[i];
		}

		while(left>=1&&right<=m2)
		{
			if(a1[left]!=a1[right])
				res--;
		}
		System.out.println(res);
	}
	public static void main(String[] zima)
	{
		Scanner sc=new Scanner(System.in);

		int m1=sc.nextInt();
		int m2=sc.nextInt();
		int[] a1=new int[m1+1];

		for(int i=1;i<m1+1;i++)
			a1[i]=sc.nextInt();

		solution(a1,m1,m2);
		sc.close();
	}
}


package test.java;
import java.util.Scanner;

public class Matrix {

    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int num=sc.nextInt();
        int lowermax=1;
        int uppermax=1;
        int side=-1;
       do {
           side+=2;
            lowermax= uppermax;
            uppermax= (((side/2)+1)*((side/2)+1)) + ((side/2)*(side/2));

        } while (!(lowermax <= num && num <= uppermax ));

 System.out.println(side);
    }

}


import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map.Entry;
import java.util.Scanner;

public class Main {

    public void solve() {
        Scanner sc=new Scanner(System.in);

        int n=sc.nextInt();

        if(n==1){
            ln(1);
            return;
        }
        if(n==3){
            ln(5);
            return;
        }

        if(1<=n && n<=5){
            ln(3);
            return;
        }
        if(5<n && n<=13){
            ln(5);
            return;
        }
        if(13<n && n<=29){
            ln(7);
            return;
        }
        if(29<n && n<=61){
            ln(9);
            return;
        }
        if(61<n && n<=100){
            ln(11);
            return;
        }
    }

    public void run() {
        solve();
    }

    public static void main(String[] _) {
        new Main().run();
    }

    public static void ln() {
        System.out.println();
    }
    public static void ln(Object o) {
        System.out.println(o);
    }

    public static void pr(Object o) {
        System.out.print(o);
    }

}


import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {

    public static void main(String[] args) {
        InputStream inputStream=System.in;
        /*
        try{
            inputStream=new FileInputStream("input.txt");
        } catch (IOException e){throw new RuntimeException(e);}
        //*/
        OutputStream outputStream=System.out;
        InputReader in=new InputReader(inputStream);
        PrintWriter out=new PrintWriter(outputStream);
        Task solver=new Task();
        solver.run(in,out);
        out.close();
    }

}

class Task{
    public void run(InputReader in, PrintWriter out){
        int x=in.nextInt(),n,y,s;
        n=x/4;
        //if (x==2){out.println(2); return;}
        //if (x==3){out.println(5); return;}
        for (int i=0;i<=x*2+1;i++){
            y=(i*i+1)/2;
            s=i/2;
            if (x%4>1) s--;
            if (s<0) continue;
            y+=s;
            if (y>=n) {out.println(i*2+1); return;}
        }
    }
}

class InputReader{
    private BufferedReader reader;
    private StringTokenizer tokenizer;
    public InputReader(InputStream stream){
        reader=new BufferedReader(new InputStreamReader(stream));
        tokenizer=null;
    }
    public String next(){
        while (tokenizer==null||!tokenizer.hasMoreTokens()){
            try{
                tokenizer=new StringTokenizer(reader.readLine());
            } catch (IOException e){
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }
    public int nextInt(){
        return Integer.parseInt(next());
    }
}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.BufferedWriter;
import java.io.Writer;
import java.io.OutputStreamWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;
/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Alex
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        OutputWriter out = new OutputWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }
    static class TaskA {
        boolean f(int i1, int j1, int i2, int j2) {
            if (i1 == i2 && j1 == j2) return false;
            return Math.abs(i1 - i2) + Math.abs(j1 - j2) <= 1;
        }
        int good(int n) {
            boolean[][] taken = new boolean[n][n];
            for (int i = 0; i < n; i++) {
                outer:
                for (int j = 0; j < n; j++) {
                    if (f(i, j, n - i - 1, j) || f(i, j, i, n - j - 1) || f(i, j, n - i - 1, n - j - 1)) {
                        continue;
                    }
                    for (int k = 0; k < 4; k++) {
                        int ni = i + MiscUtils.DX4[k];
                        int nj = j + MiscUtils.DY4[k];
                        if (MiscUtils.isValidCell(ni, nj, n, n)) {
                            if (taken[ni][nj]) {
                                continue outer;
                            }
                        }
                    }
                    taken[i][j] = true;
                }
            }
            int res = 0;
            for (boolean[] bb : taken) for (boolean b : bb) if (b) res++;
            return res;
        }
        public void solve(int testNumber, InputReader in, OutputWriter out) {
            int x = in.readInt();
            for (int side = 1; side <= 1000; side++) {
                int can = good(side);
                if (x % 4 == 0) {
                    if (can >= x) {
                        out.printLine(side);
                        return;
                    }
                }
                if (x % 4 == 1) {
                    if (can % 4 == 1) {
                        if (can >= x) {
                            out.printLine(side);
                            return;
                        }
                    }
                }
            }
        }
    }
    static class OutputWriter {
        private final PrintWriter writer;
        public OutputWriter(OutputStream outputStream) {
            writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
        }
        public OutputWriter(Writer writer) {
            this.writer = new PrintWriter(writer);
        }
        public void close() {
            writer.close();
        }
        public void printLine(int i) {
            writer.println(i);
        }
    }
    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private InputReader.SpaceCharFilter filter;
        public InputReader(InputStream stream) {
            this.stream = stream;
        }
        public int read() {
            if (numChars == -1)
                throw new InputMismatchException();
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }
        public int readInt() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }
        public boolean isSpaceChar(int c) {
            if (filter != null)
                return filter.isSpaceChar(c);
            return isWhitespace(c);
        }
        public static boolean isWhitespace(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }
        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);
        }
    }
    static class MiscUtils {
        public static final int[] DX4 = {1, 0, -1, 0};
        public static final int[] DY4 = {0, -1, 0, 1};
        public static boolean isValidCell(int row, int column, int rowCount, int columnCount) {
            return row >= 0 && row < rowCount && column >= 0 && column < columnCount;
        }
    }
}


import java.util.*;
public class Moon{
	public static void main(String args[]){
		Scanner sc = new Scanner (System.in);
		int n =sc.nextInt();
		int a[] = new int[n];

		for(int i=0;i<n;i++){
			a[i] = sc.nextInt();
		}

		if(n!=1){
		/*else if(n1==15){
			System.out.println("UP");
		}*/
			int n1 = a[n-1];
			int n2 = a[n-2];
			if(n1==15 && n2==14){
				System.out.println("DOWN");
			}
			else if(n1==0 && n2==1){
				System.out.println("UP");
			}
			else if(n1<n2){
				System.out.println("DOWN");
			}else if(n1>n2){
				System.out.println("UP");
			}
		}else if(a[n-1]==15){
			System.out.println("DOWN");
		}else if(a[n-1]==0){
			System.out.println("UP");
		}else {
			System.out.println("-1");
		}
	}
}


import java.util.Scanner;

public class VityaInTheCountrySide{

	public static void main(String[] args){
		Scanner input = new Scanner(System.in);
		int n = input.nextInt();
		int[] a = new int[100];

		for(int i = 0; i < n; i++) {
			a[i] = input.nextInt();
		}

		if (a[n-1] == 15){
			System.out.println("DOWN");

		}else if (a[n-1] == 0){
			 System.out.println("UP");

		}else if (n == 1){
			 System.out.println("-1");

		}else if (a[n-2] > a[n-1]){
			 System.out.println("DOWN");

		}else{
			 System.out.println("UP");

		input.close();
	}
}
}


import java.util.Scanner;
public class problem {
    public static void main(String[] args) {
       Scanner input = new Scanner(System.in);
       int n,i,res,res1,res2;
       int[] number = new int[100000];
       n = input.nextInt();
       for(i=0;i<n;i++){
           number[i] = input.nextInt();
       }
       if(n==1){
           if(number[0]==0)System.out.println("UP");
           else if(number[0]==15)System.out.println("DOWN");
           else System.out.println("-1");
       }
       else {
           res = number[n-1]-number[n-2];
            if((res>0&&n!=1&&number[n-1]!=15)||number[n-1]==0)System.out.println("UP");
            else if (res<0||number[n-1]==15)System.out.println("DOWN");
            else System.out.println("-1");
       }
    }
}


import java.io.*;
import java.util.*;

public class Main {

	public static void main(String[] args) {

		FastReader scan = new FastReader();

		int n = scan.nextInt();
		int a = 0;
		int b = 0;
		boolean ans = false;
		boolean none = false;

		for(int i=0; i<n; i++) {
			b = a;
			a = scan.nextInt();
		}

		if(n == 1) {
			if(a == 15) System.out.println("DOWN");
			else if(a == 0) System.out.println("UP");
			else System.out.println(-1);
			none = true;
		} else {
			if(a - b > 0) {
				if(a != 15) System.out.println("UP");
				else System.out.println("DOWN");
			} else if(a - b < 0) {
				if(a == 0) System.out.println("UP");
				else System.out.println("DOWN");
			}
		}

  }

	// sieveOfEratosthenes
	public static boolean[] sieve(int n) {
		boolean[] prime = new boolean[n+1];

		Arrays.fill(prime, true);
		prime[0] = false;
		prime[1] = false;

		for(int i=2; i*i<n; i++) {
			if(prime[i] == true) {
				for(int j=i*2; j<=n; j+=i) {
					prime[j] = false;
				}
			}
		}

		return prime;
	}

	//smallestFactor function
	public static long smallestFactor(long n) {
		int i;
		for(i=2; i*i<n; i++) {
			if(n%i == 0)
				break;
		}
		return i;
	}

	//FastReader Class
	static class FastReader
	{
		BufferedReader br;
		StringTokenizer st;

		public FastReader()
		{
			br = new BufferedReader(new
					InputStreamReader(System.in));
		}

		String next()
		{
			while (st == null || !st.hasMoreElements())
			{
				try
				{
					st = new StringTokenizer(br.readLine());
				}
				catch (IOException e)
				{
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

		int nextInt()
		{
			return Integer.parseInt(next());
		}

		long nextLong()
		{
			return Long.parseLong(next());
		}

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

		char[] nextChar()
		{
			return next().toCharArray();
		}

		String nextLine()
		{
			String str = "";
			try
			{
				str = br.readLine();
			}
			catch (IOException e)
			{
				e.printStackTrace();
			}
			return str;
		}
	}
}


import java.io.*;
import java.util.*;

public class Main
{
    public static void main(String[] args) throws Exception
    {
        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
        String s = sc.nextLine();
        int count=0;
        while(s.length()!=0){
            String k = " " + s.charAt(0);
            count++;
            s.replaceAll(k,"");
        }
        if(count%2==0) out.print("CHAT WITH HER!");
        if(count%2==0) out.print("IGNORE HIM!");
        out.close();
    }
}


import java.util.Scanner;

/**
 * Created by vlad on 28.07.16.
 */
public class a146 {
    public static void main(String[] args) {
        String s1="";

        Scanner scanner = new Scanner(System.in);

        s1=scanner.nextLine();
            if (isOdd(s1))
            {
                System.out.println("CHAT WITH HER!");
            }
            else
            {
                System.out.println("IGNORE HIM!");
            }

    }
    public static boolean isOdd(String s){
        int charnumbers=0;
        for(int i=0;i<26;i++)
        {
            char upper = (char)('A'+i);
            char lower = (char)('a'+i);
            boolean t=true;
            while(t)
            {
                int k=0;
                if(((s.contains(Character.toString(upper)))||(s.contains(Character.toString(lower))))&&(k==0))
                {
                    charnumbers++;
                    k++;
                }
                else if (((s.contains(Character.toString(upper)))||(s.contains(Character.toString(lower))))&&(k!=0))
                {

                }
                else if (!(s.contains(Character.toString(upper)))&&!(s.contains(Character.toString(lower))))
                {
                    t=false;
                }
            }
        }
        if(charnumbers%2==0)
        return true;
        else return false;
    }
}


import java.util.Scanner;
public class BoyOrGirl{
    public static void main(String args[]){
        Scanner sc=new Scanner(System.in);
        String s=sc.nextLine();
        int c=0,j=0;
        for(int i=0;i<s.length();i++){
            j=i-1;
            while(j>0){
                if(s.charAt(i)==s.charAt(j)){
                   c++;
                   continue;
                }
                j--;

            }
        }
        if((s.length()-c)%2==0){
            System.out.println("IGNORE HIM!");
        }
        else{
            System.out.println("CHAT WITH HER!");
        }
    }
}


import java.util.Scanner;
public class BoyOrGirl{
    public static void main(String args[]){
        Scanner sc=new Scanner(System.in);
        String s=sc.nextLine();
        int c=0,j=0;
        for(int i=0;i<s.length();i++){
            j=i-1;
            while(j>=0){
                if(s.charAt(i)==s.charAt(j)){
                   c++;
                   continue;
                }
                j--;

            }
        }
        if((s.length()-c)%2==0){
            System.out.println("IGNORE HIM!");
        }
        else{
            System.out.println("CHAT WITH HER!");
        }
    }
}


import java.io.*;
import java.util.Arrays;
import static java.lang.Math.*;

public class ProblemD {

  public static void main(String[] args) throws IOException {
    init();
    new ProblemD().run();
    out.flush();
    out.close();
  }

  static void init() throws IOException {
    in = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));
    out = new PrintWriter(new OutputStreamWriter(System.out));
    in.ordinaryChars(0, 65535);
    in.wordChars(0, 65535);
    in.whitespaceChars(' ', ' ');
    in.whitespaceChars('\n', '\n');
    in.whitespaceChars('\r', '\r');
  }

  // класс для пар
  class Pair<L, R> implements Comparable{
    private final L X;
    private final R Y;

    public Pair(L X, R Y) {
      this.X = X;
      this.Y = Y;
    }

    public L getX() {
      return X;
    }

    public R getY() {
      return Y;
    }

    @Override
    public int hashCode() {
      return X.hashCode() ^ Y.hashCode();
    }

    @Override
    public boolean equals(Object o) {
      if (!(o instanceof Pair)) return false;
      Pair pairo = (Pair) o;
      return X.equals(pairo.getX()) && Y.equals(pairo.getY());
    }

    @Override
    public String toString() {
      return "Pair{" +
              "X=" + X +
              ", Y=" + Y +
              '}';
    }

    @Override
    public int compareTo(Object o) {
      Pair<L, R> oPair = (Pair<L, R>)o;
      Comparable cX = (Comparable)this.X;
      Comparable cY = (Comparable)this.Y;
      if (cX.compareTo(oPair.X) > 0 || (cX.compareTo(oPair.X) == 0 && cY.compareTo(oPair.Y) > 0)) {
        return 1;
      } else if (cX.compareTo(oPair.X) == 0 && cY.compareTo(oPair.Y) == 0) {
        return 0;
      } else {
       return -1;
      }
    }
  }

  static final long INFL = 200000000000000000L;
  static final int INF = 2000000000;
  static final boolean DEBUG = true;

  static StreamTokenizer in;
  static PrintWriter out;

  static void print(String s) {
    print(s, 0);
  }

  static void print(String s, int debug) {
    if (debug == 0 || DEBUG) {
      out.print(s);
    }
  }

  static void println(String s) {
    println(s, 0);
  }

  static void println(String s, int debug) {
    if (debug == 0 || DEBUG) {
      out.println(s);
    }
  }

  static void printArray(int[] arr) {
    println(Arrays.toString(arr));
  }

  static void printArray(char[] arr) {
    println(Arrays.toString(arr));
  }

  static void printArray(String[] arr) {
    println(Arrays.toString(arr));
  }

  static char[] inChars;
  static int inCharsInd;

  static String next() throws IOException {
    in.nextToken();
    return in.sval;
  }

  static char nextChar() throws IOException {
    while (inChars == null || inCharsInd >= inChars.length) {
      inChars = next().toCharArray();
      inCharsInd = 0;
    }
    return inChars[inCharsInd++];
  }

  static int nextInt() throws IOException {
    return Integer.valueOf(next());
  }

  static double nextDouble() throws IOException {
    return Double.valueOf(next());
  }

  static long nextLong() throws IOException {
    return Long.valueOf(next());
  }

  private void run() throws IOException {
    solve();
  }

  long M;
  Pair <Long, Long> best = new Pair<>(0L, 0L);

  private void solve() throws IOException {
    M = nextLong();
    recur(M, 0, 0);
    out.println(best.getX() + " " + best.getY());
  }

  private void recur(long M, long steps, long substracted) {
//    out.println(M);
    if (M == 0){
      Pair p = new Pair(steps, substracted);
      best = (best.compareTo(p)>=0)?best:p;
      return;
    }
    long sqrt = 1;
    while(pow(sqrt+1, 3) <= M) sqrt++;
    long myPow = (long)pow(sqrt, 3);
    recur(M - myPow, steps+1, substracted + myPow);
    if (sqrt - 1 >= 1){
      long myPowMinus = (long)pow(sqrt-1, 3);
      recur(myPow - 1 - myPowMinus, steps+1, substracted + myPowMinus);
    }
  }

}


import java.util.Scanner;

public class D356 {

    public static Result best;

    public static void main(String[] args) {

        Scanner scanner = new Scanner(System.in);

        long m = scanner.nextInt();

        search(m, 0, 0);

        System.out.printf("%s %s\n", best.steps, best.number);

    }

    private static void search(long m, int step, long num) {
        //System.out.println(m);
        if (m == 0) {
            Result current = new Result(num, step);
            if (best == null || best.compareTo(current) < 0) {
                 best = current;
            }
            return;
        }

        long x = 1;
        while (cubic(x + 1) <= m) {
            x++;
        }
        search(m - cubic(x), step + 1, num + cubic(x));
        if (x - 1 >= 0) {
            search(cubic(x) - 1 - cubic(x - 1), step + 1, num + cubic(x - 1));
        }
    }

    private static long cubic(long x) {
        return x * x * x;
    }

    public static class Result implements Comparable<Result> {
        long number;
        int steps;

        public Result(long number, int steps) {
            this.number = number;
            this.steps = steps;
        }

        @Override
        public int compareTo(Result o) {
            int cmp = Integer.compare(steps, o.steps);
            if (cmp == 0) {
                cmp = Long.compare(number, o.number);
            }
            return cmp;
        }
    }
}


import java.io.*;
import java.util.*;

public class bear_tower
{

	public long floorCube(long n)
	{
		for (long i = 1; i<= n; i++)
		{
			if (i*i*i > n)
				return(i-1);
			else if (i*i*i == n)
				return(i);
		}
		return(0);

	}

	public long Cube(long j)
	{
		return(j*j*j);
	}

	public long NoCubes(long k)
	{
		long volleft = k;
		long num = 0;
			while (volleft != 0)
			{
				long j = floorCube(volleft);

				if (j == 1)
				{
					num += volleft;
					volleft = 0;
					break;
				}

				volleft -= Cube(j);
				num += 1;
			}

		return(num);
	}

	public static void main(String args[])throws IOException
	{
		Scanner sc = new Scanner (System.in);
		long m = sc.nextLong();
		bear_tower dd = new bear_tower();
		long max = 0;
		long X = 0;
		int [] index = new int [(int)(m/(long)Math.sqrt(m)) + 1];
		int [] ind_start = new int [(int)(m/(long)Math.sqrt(m)) ];
		int [] ind_stop = new int [(int)(m/(long)Math.sqrt(m)) ];
		int k = 0;
		for (int i = 0;  i < m ; i+= (int)Math.sqrt(m))
		{
			if (k<=(int)(m/(long)Math.sqrt(m)))
			{
				index[k] = i;
				if (k > 0)
					ind_start[k] = index[k]+1;
				else
					ind_start[k] = index[k];

				ind_stop[k] = index[k] + (int)Math.sqrt(m);
				k++;

			}

		}

		long [] to = new long [2];
		long ma = 0;

		for (int i = 0; i< ind_start.length; i++)
		{
			long two = Math.max(dd.NoCubes(ind_start[i]), dd.NoCubes(ind_stop[i]));
			//System.out.println(ind_start[i]+"-->"+ind_stop[i]+" "+two+" "+ma);
			if (ma < two)
			{
				to[0] = ind_start[i];
				to[1] = ind_stop[i];
				ma = two;

			}

		}

		//System.out.println(to[0]+" "+to[1]);

		for (long i = to[0]; i <= to[1]; i++)
		{
			if (dd.NoCubes(i) >= max)
			{
				max = dd.NoCubes(i);
				X = i;
			}
		}
		System.out.println(max+" "+X);

	}

}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

/**
 * @author Don Li
 */
public class BearTowerCubes {

    static final int MAXN = 100001;

    long[] p = new long[MAXN];

    {
        for (int i = 1; i < MAXN; i++) p[i] = (long) i * i * i;
    }

    void solve() {
        long m = in.nextLong();
        long sum = 0, cnt = 0;
        while (m > 0) {
            int x = 1;
            while (p[x + 1] <= m) x++;
            if (steps(m) == 1 + steps(m - p[x])) {
                m -= p[x];
                sum += p[x];
            } else {
                m = p[x] - 1 - p[x - 1];
                sum += p[x - 1];
            }
            cnt++;
        }
        out.printf("%d %d%n", cnt, sum);
    }

    long steps(long m) {
        if (m < 8) return m;
        int x = 1;
        while (p[x + 1] <= m) x++;
        return 1 + steps(Math.max(m - p[x], p[x] - 1 - p[x - 1]));
    }

    public static void main(String[] args) {
        in = new FastScanner(new BufferedReader(new InputStreamReader(System.in)));
        out = new PrintWriter(System.out);
        new BearTowerCubes().solve();
        out.close();
    }

    static FastScanner in;
    static PrintWriter out;

    static class FastScanner {
        BufferedReader in;
        StringTokenizer st;

        public FastScanner(BufferedReader in) {
            this.in = in;
        }

        public String nextToken() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(in.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(nextToken());
        }

        public long nextLong() {
            return Long.parseLong(nextToken());
        }

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


import java.util.*;
public class codechef
{
	public static long fact(int n)
	{
		long arr[] = new long[n+1];
		arr[0]=1;
		arr[1]=1;
		for(int i =2;i<n+1;i++)
		{
			arr[i]=i*arr[i-1];
		}
		return arr[n];

	}
	public static long combi(int n,int r)
	{
		return fact(n)/(fact(r)*fact(n-r));
	}
    public static void main(String args[])
    {
       Scanner x = new Scanner(System.in);
       int n = x.nextInt();
       int m = x.nextInt();
       long min,max;
       if(n%m==0)
       {
       	min = combi((int)Math.ceil(1.0*n/m),2)*m;
       }
       else
       	min = combi((int)Math.ceil(1.0*n/m),2)*m-(int)Math.ceil((n-m)/2.0);
       max = combi(n-(m-1),2);
       System.out.println(min+" "+max);
    }
    /*public static void main(String args[])
    {
    	Scanner x = new Scanner(System.in);
    	int t = x.nextInt();
    	while(--t>=0)
    	{
    		int d = x.nextInt();
    		String st = x.next();
    		int p =0;
    		int c =0;
    		for(int i =0;i<d;i++)
    		{
    			if(st.charAt(i)=='P')
    			{
                    c++;
    			}
    		}
    		int l = (int)Math.rint(d*0.75);
    		c = l-c;
    		for(int i = 2;i<d-2;i++)
    		{
    			if(p==c)
    				break;
    			if(st.charAt(i)=='P')
    				continue;
    			else
    			{
    				if((st.charAt(i-1)=='P'||st.charAt(i-2)=='P')&&(st.charAt(i+1)=='P'||st.charAt(i+2)=='P'))
    				{
    					p++;
    				}
    			}
    		}
    		if(p==c)
    		{
    			System.out.println(p);
    		}
    		else
    			System.out.println(-1);
    	}*/
    }


import java.util.Scanner;

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
/**
 *
 * @author KHALED
 */
public class RandomTeams {
    public static int getFact(int x)
    {
        if(x==1)
            return 1;
        return x*getFact(x-1);
    }
    public static int getMax(int m, int n)
    {
        int k=m,h=n;
        int[]arr=new int[h];
        for (int i = 0; i < h-1; i++)
        {
            arr[i]=1;
            k--;
        }
        arr[h-1]=k;
        if(k==1)
            return 0;
        return (getFact(k)/(getFact(k-2)*getFact(2)));
    }
    public static int getMin(int m, int n)
    {
        int k=m,h=n;
        int[]arr=new int[h];
        int total = 0;
        if(h>1)
        {
            int z=k;
            int count=0;
            while(z>=h)
            {
                z=z-h;
                count++;
            }
            for (int i = 0; i < h; i++)
            {
                arr[i]=count;
                if(i<z)
                    arr[i]++;
                if(arr[i]>=2)
                {
                    total+=(getFact(arr[i])/(getFact(arr[i]-2)*getFact(2)));
                }
            }
        }
        else
        {
            arr[0]=k;
            if(arr[0]>=2)
            {
                total+=(getFact(arr[0])/(getFact(arr[0]-2)*getFact(2)));
            }
        }
        return total;
    }
    public static void main(String[] args)
    {
            Scanner scan=new Scanner(System.in);
            int m=scan.nextInt();   //members number
            int n=scan.nextInt();   //teams number
            System.out.println(getMin(m, n)+" "+getMax(m, n));

    }
}


package Practice;
import java.io.*;
import java.util.*;
public class ACM_Anyone {

    private static final Scanner LS = new Scanner(System.in);
    private static final BufferedReader LF = new BufferedReader(new InputStreamReader(System.in));
    private static final BufferedWriter EF = new BufferedWriter(new OutputStreamWriter(System.out));
    public static void main(String[] args) throws IOException {

        int m = LS.nextInt() , n = LS.nextInt();
        int min = m / n;
        long qmin;
        if (m % n == 0)
            qmin = n * ((min - 1) + (min - 1) * (min - 1)) / 2;
        else {
            qmin = (((min - 1) + (min - 1) * (min - 1)) / 2) + (m % n) * (((min) + (min) * (min)) / 2);
        }
        for (int i = 1 ; i <= 10; i++) {

        }
        long qmax = ((m - n) + (m - n) * (m - n)) / 2;
        System.out.println(qmin+" "+qmax);
    }
}


import java.util.*;
public class codechef
{
	public static int fact(int n)
	{
		if(n<2)
			return 1;
		return n*fact(n-1);
	}
	public static int combi(int n,int r)
	{
		return fact(n)/(fact(r)*fact(n-r));
	}
    public static void main(String args[])
    {
       Scanner x = new Scanner(System.in);
       int n = x.nextInt();
       int m = x.nextInt();
       int min,max;
       if(n%m==0)
       {
       	min = combi((int)Math.ceil(1.0*n/m),2)*m;
       }
       else
       	min = combi((int)Math.ceil(1.0*n/m),2)*m-(int)Math.ceil((n-m)/2.0);
       max = combi(n-(m-1),2);
       System.out.println(min+" "+max);
    }
}