import java.io.*;

public class B851 {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] tokens = br.readLine().split(" ");
        long ax = Integer.parseInt(tokens[0]);
        long ay = Integer.parseInt(tokens[1]);
        long bx = Integer.parseInt(tokens[2]);
        long by = Integer.parseInt(tokens[3]);
        long cx = Integer.parseInt(tokens[4]);
        long cy = Integer.parseInt(tokens[5]);

        long ab2 = (ax - bx) * (ax - bx) + (ay - by) * (ay - by);
        long bc2 = (bx - cx) * (bx - cx) + (by - cy) * (by - cy);

        long slopeTop = (by - ay)
        long slopeBot = (bx - ax);
        double lhs = slopeBot * (cy - ay);
        double rhs = slopeTop * (cx - ax);
        if (lhs == rhs) {
            System.out.println("No");
        } else {
            String ans = "";
            if (ab2 == bc2) {
                ans = "Yes";
            } else {
                ans = "No";
            }
            System.out.println(ans);
        }
    }
}


import java.util.*;
public class Main
{
    public static void main(String [] args)
    {
        int aold,anew,bold,bnew,cold,cnew;
        Scanner input = new Scanner(System.in);
        aold = input.nextInt();
        anew = input.nextInt();
        bold = input.nextInt();
        bnew = input.nextInt();
        cold = input.nextInt();
        cnew = input.nextInt();
        if (((2*bnew)-anew-cnew)*(cnew-anew)==(aold+cold-(2*bold))*(cold-aold) && !(2*bold==aold+cold && 2*bnew==anew+cnew))
        {
            System.out.println("Yes");
        }
        else
        {
            System.out.println("No");
        }

    }


import java.util.Scanner;

public class G {
    static long mod = 998244353;

    static int N = 1 << 20;
    static int r[] = new int[N];

    static long A[] = new long[N];
    static long B[] = new long[N];
    static long C[] = new long[N];

    static long base[] = new long[N];

    static long pow(long a, long b) {
        if (b == 0) {
            return 1;
        }
        if (b % 2 == 0) {
            return pow(a * a % mod, b / 2);
        } else {
            return pow(a * a % mod, b / 2) % mod * a % mod;
        }
    }

    static void ntt(long[] x, int lim, int opt) {
        int i, j, k, m;
        for (i = 0; i < lim; ++i)
            if (r[i] < i) {
                //swap(x[i], x[r[i]]);
                long tmp = x[i];
                x[i] = x[r[i]];
                x[r[i]] = tmp;

            }
        for (m = 2; m <= lim; m <<= 1) {
            k = m >> 1;
            long gn = pow(3, (mod - 1) / m);
            for (i = 0; i < lim; i += m) {
                long g = 1;
                for (j = 0; j < k; ++j, g = g * gn % mod)
                {
                    long tmp = x[i + j + k] * g % mod;
                    x[i + j + k] = (x[i + j] - tmp + mod) % mod;
                    x[i + j] = (x[i + j] + tmp) % mod;
                }
            }
        }
        if (opt == -1) {
            for (i = 1; i <= lim / 2; i++) {
                long tmp = x[i];
                x[i] = x[lim - i];
                x[lim - i] = tmp;
            }
            long inv = pow(lim, mod - 2);
            for (i = 0; i < lim; ++i)
                x[i] = x[i] * inv % mod;
        }
    }

    static void work(long[] a, long[] b, long[] c, int n) {
        ntt(a, n, 1);
        ntt(b, n, 1);
        for (int i = 0; i < n; ++i) {
            c[i] = a[i] * b[i] % mod;
        }
        ntt(c, n, -1);
    }

    static void work2(long[] a, long[] c, int n) {
        ntt(a, n, 1);
        for (int i = 0; i < n; ++i) {
            c[i] = a[i] * a[i] % mod;
        }
        ntt(c, n, -1);

//        System.out.print("work2 : ");
//        for (int i = 0; i < 100; i++) {
//            System.out.print(c[i] + " ");
//        }
//        System.out.println();
    }

    public static void main(String[] aaaa) {
        Scanner scanner = new Scanner(System.in);
        long start = System.currentTimeMillis();

        int n = scanner.nextInt() / 2;
        int k = scanner.nextInt();
        for (int i = 0; i < N; ++i)
            r[i] = (i & 1) * (N >> 1) + (r[i >> 1] >> 1);

        A[0] = 1;
        for (int i = 0; i < k; i++) {
            base[scanner.nextInt()] = 1;
        }

//        System.out.print("base : ");
//        for (int i = 0; i < 100; i++) {
//            System.out.print(base[i] + " ");
//        }
//        System.out.println();

        int nn = 10;
        while (n > 0) {
//            System.out.println(n);
            if ((n & 1) == 0) {
                //work(A, base, C);
            } else {
                System.arraycopy(base, 0, B, 0, nn);
                work(B, A, C, nn);
                System.arraycopy(C, 0, A, 0, nn);
            }
            work2(base, C, nn);
            System.arraycopy(C, 0, base, 0, nn);
            n /= 2;

            nn = Math.min(nn * 2, N);

//            System.out.print("A : ");
//            for (int i = 0; i < 100; i++) {
//                System.out.print(A[i] + " ");
//            }
//            System.out.println();

        }
        long ans = 0;
        for (int i = 0; i < N; i++) {
            ans += A[i] * A[i];
            ans %= mod;
        }
        System.out.println(ans);

//        System.out.println(System.currentTimeMillis() - start);

//        int n = 0;
//        int lim = 1;
//        String a = scanner.next();
//        n = a.length();
//        for (int i = 0; i < n; i++)
//            A[i] = a.charAt(n - i - 1) - '0';
//        while (lim < (n << 1)) lim <<= 1;
//        String b = scanner.next();
//        n = b.length();
//        for (int i = 0; i < n; i++)
//            B[i] = b.charAt(n - i - 1) - '0';
//        while (lim < (n << 1)) lim <<= 1;
//        for (int i = 0; i < lim; ++i)
//            r[i] = (i & 1) * (lim >> 1) + (r[i >> 1] >> 1);
//        ntt(A, lim, 1);
//        ntt(B, lim, 1);
//        for (int i = 0; i < lim; ++i)
//            C[i] = A[i] * B[i] % mod;
//        ntt(C, lim, -1);

//        for (int i = 0; i < lim; i++) {
//            System.out.print(C[i] + " ");
//        }
//        System.out.println();
//        int len = 0;
//        for (int i = 0; i < lim; ++i) {
//            if (C[i] >= 10) {
//                len = i + 1;
//                C[i + 1] += C[i] / 10;
//                C[i] %= 10;
//            }
//            if (C[i] != 0) {
//                len = Math.max(len, i);
//            }
//        }
//        while (C[len] >= 10) {
//            C[len + 1] += C[len] / 10;
//            C[len] %= 10;
//            len++;
//        }
//        for (int i = len; i >= 0; --i)
//            System.out.print((char)(C[i] + '0'));
//        System.out.println();
    }
}


import java.util.Scanner;

public class G {
    static long mod = 998244353;

    static int N = 1 << 20;
    static int r[] = new int[N];

    static long A[] = new long[N];
    static long B[] = new long[N];
    static long C[] = new long[N];
    static long D[];

    static long base[] = new long[N];

//    static long pow(long a, long b) {
//        if (b == 0) {
//            return 1;
//        }
//        if (b % 2 == 0) {
//            return pow(a * a % mod, b / 2);
//        } else {
//            return pow(a * a % mod, b / 2) % mod * a % mod;
//        }
//    }

    static long pow(long a, long b) {
        long ans = 1;
        while (b > 0) {
            if ((b & 1) == 1) {
                ans = ans * a % mod;
            }
            b >>= 1;
            a = a * a % mod;
        }
        return ans;
    }

    static void ntt(long[] x, int lim, int opt) {
        int i, j, k, m;
        long g, gn, tmp;
        for (i = 0; i < lim; ++i) {
            if (r[i] < i) {
                tmp = x[i];
                x[i] = x[r[i]];
                x[r[i]] = tmp;
            }
        }
        for (m = 2; m <= lim; m <<= 1) {
            k = m >> 1;
            gn = pow(3, (mod - 1) / m);
            for (i = 0; i < lim; i += m) {
                g = 1;
                for (j = 0; j < k; ++j, g = g * gn % mod)
                {
                    tmp = x[i + j + k] * g % mod;
                    x[i + j + k] = (x[i + j] - tmp + mod) % mod;
                    x[i + j] = (x[i + j] + tmp) % mod;
                }
            }
        }
        if (opt == -1) {
            for (i = 1; i <= lim / 2; i++) {
                tmp = x[i];
                x[i] = x[lim - i];
                x[lim - i] = tmp;
            }
            long inv = pow(lim, mod - 2);
            for (i = 0; i < lim; ++i)
                x[i] = x[i] * inv % mod;
        }
    }

    static void work(long[] a, long[] b, long[] c, int n) {
        ntt(a, n, 1);
        ntt(b, n, 1);
        for (int i = 0; i < n; ++i) {
            c[i] = a[i] * b[i] % mod;
        }
        ntt(c, n, -1);
    }

    static void work2(long[] a, long[] c, int n) {
        ntt(a, n, 1);
        for (int i = 0; i < n; ++i) {
            c[i] = a[i] * a[i] % mod;
        }
        ntt(c, n, -1);

//        System.out.print("work2 : ");
//        for (int i = 0; i < 100; i++) {
//            System.out.print(c[i] + " ");
//        }
//        System.out.println();
    }

    public static void main(String[] aaaa) {
        Scanner scanner = new Scanner(System.in);
        long start = System.currentTimeMillis();

        int n = scanner.nextInt() / 2;
        int k = scanner.nextInt();
//        for (int i = 0; i < N; ++i)
//            r[i] = (i & 1) * (N >> 1) + (r[i >> 1] >> 1);

        A[0] = 1;
        for (int i = 0; i < k; i++) {
            base[scanner.nextInt()] = 1;
        }

//        System.out.print("base : ");
//        for (int i = 0; i < 100; i++) {
//            System.out.print(base[i] + " ");
//        }
//        System.out.println();

        int nn = 32;
        int last = 0;
        while (n > 0) {

            if (last == nn) {

            } else {
                for (int i = 0; i < nn; ++i)
                    r[i] = (i & 1) * (nn >> 1) + (r[i >> 1] >> 1);
                last = nn;
            }

//            System.out.println(n);
            if ((n & 1) == 0) {
                //work(A, base, C);
            } else {
                System.arraycopy(base, 0, B, 0, nn);
                work(B, A, C, nn);
                //System.arraycopy(C, 0, A, 0, nn);
                D = C;
                C = A;
                A = D;
            }
            n /= 2;

            if (n > 0)
                work2(base, C, nn);
            D = C;
            C = base;
            base = D;
            //System.arraycopy(C, 0, base, 0, nn);

            nn = Math.min(nn * 2, N);

//            System.out.print("A : ");
//            for (int i = 0; i < 100; i++) {
//                System.out.print(A[i] + " ");
//            }
//            System.out.println();

        }
        long ans = 0;
        for (int i = 0; i < nn; i++) {
            ans += A[i] * A[i];
            ans %= mod;
        }
        System.out.println(ans);

        System.out.println(System.currentTimeMillis() - start);

//        int n = 0;
//        int lim = 1;
//        String a = scanner.next();
//        n = a.length();
//        for (int i = 0; i < n; i++)
//            A[i] = a.charAt(n - i - 1) - '0';
//        while (lim < (n << 1)) lim <<= 1;
//        String b = scanner.next();
//        n = b.length();
//        for (int i = 0; i < n; i++)
//            B[i] = b.charAt(n - i - 1) - '0';
//        while (lim < (n << 1)) lim <<= 1;
//        for (int i = 0; i < lim; ++i)
//            r[i] = (i & 1) * (lim >> 1) + (r[i >> 1] >> 1);
//        ntt(A, lim, 1);
//        ntt(B, lim, 1);
//        for (int i = 0; i < lim; ++i)
//            C[i] = A[i] * B[i] % mod;
//        ntt(C, lim, -1);

//        for (int i = 0; i < lim; i++) {
//            System.out.print(C[i] + " ");
//        }
//        System.out.println();
//        int len = 0;
//        for (int i = 0; i < lim; ++i) {
//            if (C[i] >= 10) {
//                len = i + 1;
//                C[i + 1] += C[i] / 10;
//                C[i] %= 10;
//            }
//            if (C[i] != 0) {
//                len = Math.max(len, i);
//            }
//        }
//        while (C[len] >= 10) {
//            C[len + 1] += C[len] / 10;
//            C[len] %= 10;
//            len++;
//        }
//        for (int i = len; i >= 0; --i)
//            System.out.print((char)(C[i] + '0'));
//        System.out.println();
    }
}


import java.util.Scanner;

public class G {
    static long mod = 998244353;

    static int N = 1 << 20;
    static int r[] = new int[N];

    static long A[] = new long[N];
    static long B[] = new long[N];
    static long C[] = new long[N];
    static long D[];

    static long base[] = new long[N];

//    static long pow(long a, long b) {
//        if (b == 0) {
//            return 1;
//        }
//        if (b % 2 == 0) {
//            return pow(a * a % mod, b / 2);
//        } else {
//            return pow(a * a % mod, b / 2) % mod * a % mod;
//        }
//    }

    static long pow(long a, long b) {
        long ans = 1;
        while (b > 0) {
            if ((b & 1) == 1) {
                ans = ans * a % mod;
            }
            b >>= 1;
            a = a * a % mod;
        }
        return ans;
    }

    static void ntt(long[] x, int lim, int opt) {
        int i, j, k, m;
        long g, gn, tmp;
        for (i = 0; i < lim; ++i) {
            if (r[i] < i) {
                tmp = x[i];
                x[i] = x[r[i]];
                x[r[i]] = tmp;
            }
        }
        for (m = 2; m <= lim; m <<= 1) {
            k = m >> 1;
            gn = pow(3, (mod - 1) / m);
            for (i = 0; i < lim; i += m) {
                g = 1;
                for (j = 0; j < k; ++j, g = g * gn % mod)
                {
                    tmp = x[i + j + k] * g % mod;
                    x[i + j + k] = (x[i + j] - tmp + mod) % mod;
                    x[i + j] = (x[i + j] + tmp) % mod;
                }
            }
        }
        if (opt == -1) {
            for (i = 1; i <= lim / 2; i++) {
                tmp = x[i];
                x[i] = x[lim - i];
                x[lim - i] = tmp;
            }
            long inv = pow(lim, mod - 2);
            for (i = 0; i < lim; ++i)
                x[i] = x[i] * inv % mod;
        }
    }

    static void work(long[] a, long[] b, long[] c, int n) {
        ntt(a, n, 1);
        ntt(b, n, 1);
        for (int i = 0; i < n; ++i) {
            c[i] = a[i] * b[i] % mod;
        }
        ntt(c, n, -1);
    }

    static void work2(long[] a, long[] c, int n) {
        ntt(a, n, 1);
        for (int i = 0; i < n; ++i) {
            c[i] = a[i] * a[i] % mod;
        }
        ntt(c, n, -1);

//        System.out.print("work2 : ");
//        for (int i = 0; i < 100; i++) {
//            System.out.print(c[i] + " ");
//        }
//        System.out.println();
    }

    public static void main(String[] aaaa) {
        Scanner scanner = new Scanner(System.in);
        long start = System.currentTimeMillis();

        int n = scanner.nextInt() / 2;
        int k = scanner.nextInt();
//        for (int i = 0; i < N; ++i)
//            r[i] = (i & 1) * (N >> 1) + (r[i >> 1] >> 1);

        int m[] = new int[1 << 21];
        m[0] = 1;
        for (int i = 1; i < m.length; i++) {
            if (i == m[i - 1]) {
                m[i] = i * 2;
            } else {
                m[i] = m[i - 1];
            }
        }

        A[0] = 1;
        for (int i = 0; i < k; i++) {
            base[scanner.nextInt()] = 1;
        }

//        System.out.print("base : ");
//        for (int i = 0; i < 100; i++) {
//            System.out.print(base[i] + " ");
//        }
//        System.out.println();

        int nn = 18;
        int nnn = 18;
        int last = 0;
        while (n > 0) {

            nn = m[nnn];
            if (nn > (1 << 20)) {
                nn = 1 << 20;
            }
            if (last == nn) {

            } else {
                for (int i = 0; i < nn; ++i)
                    r[i] = (i & 1) * (nn >> 1) + (r[i >> 1] >> 1);
                last = nn;
            }

//            System.out.println(n);
            if ((n & 1) == 0) {
                //work(A, base, C);
            } else {
                System.arraycopy(base, 0, B, 0, nn);
                work(B, A, C, nn);
                //System.arraycopy(C, 0, A, 0, nn);
                D = C;
                C = A;
                A = D;
            }
            n /= 2;

            if (n > 0)
                work2(base, C, nn);
            D = C;
            C = base;
            base = D;
            //System.arraycopy(C, 0, base, 0, nn);

            nnn <<= 1;
//            System.out.print("A : ");
//            for (int i = 0; i < 100; i++) {
//                System.out.print(A[i] + " ");
//            }
//            System.out.println();

        }
        long ans = 0;
        for (int i = 0; i < nn; i++) {
            ans += A[i] * A[i];
            ans %= mod;
        }
        System.out.println(ans);

        System.out.println(System.currentTimeMillis() - start);

//        int n = 0;
//        int lim = 1;
//        String a = scanner.next();
//        n = a.length();
//        for (int i = 0; i < n; i++)
//            A[i] = a.charAt(n - i - 1) - '0';
//        while (lim < (n << 1)) lim <<= 1;
//        String b = scanner.next();
//        n = b.length();
//        for (int i = 0; i < n; i++)
//            B[i] = b.charAt(n - i - 1) - '0';
//        while (lim < (n << 1)) lim <<= 1;
//        for (int i = 0; i < lim; ++i)
//            r[i] = (i & 1) * (lim >> 1) + (r[i >> 1] >> 1);
//        ntt(A, lim, 1);
//        ntt(B, lim, 1);
//        for (int i = 0; i < lim; ++i)
//            C[i] = A[i] * B[i] % mod;
//        ntt(C, lim, -1);

//        for (int i = 0; i < lim; i++) {
//            System.out.print(C[i] + " ");
//        }
//        System.out.println();
//        int len = 0;
//        for (int i = 0; i < lim; ++i) {
//            if (C[i] >= 10) {
//                len = i + 1;
//                C[i + 1] += C[i] / 10;
//                C[i] %= 10;
//            }
//            if (C[i] != 0) {
//                len = Math.max(len, i);
//            }
//        }
//        while (C[len] >= 10) {
//            C[len + 1] += C[len] / 10;
//            C[len] %= 10;
//            len++;
//        }
//        for (int i = len; i >= 0; --i)
//            System.out.print((char)(C[i] + '0'));
//        System.out.println();
    }
}


import java.util.Arrays;
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 Andy Phan
 */
public class p1096g {
    static long MOD = 998244353;

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int k = in.nextInt();
        long[] base = new long[10];
        for(int i = 0; i < k; i++) base[in.nextInt()] = 1;
        long[] res = expo(base, n>>1);
        long tot = 0;
        for(long e : res) tot = (tot+(e*e)%MOD)%MOD;
        System.out.println(tot);
    }

    static long[] expo(long[] orig, long pow) {
        if(pow == 1) return orig;
        if((pow&1) != 0) return FFT.multiplyPrecise(orig, expo(orig, pow-1));
        long[] tmp = expo(orig, pow>>1);
        return FFT.multiplyPrecise(tmp, tmp);
    }

    // SET maxk appropriately!!! ~log(maxn) //%
    static class FFT {
        static final int maxk = 23, maxn = (1 << maxk) + 1;
        // Init: wR, wI, rR, rI, aR, aI   to   new double[maxn] !!!
        //#
        static double[] wR = new double[maxn],
                wI = new double[maxn],
                rR = new double[maxn],
                rI = new double[maxn],
                aR  = new double[maxn],
                aI  = new double[maxn]; //$
        static int n, k, lastk = -1, dp[] = new int[maxn];

        static void fft(boolean inv) {
            if (lastk != k) {
                lastk = k;  dp[0] = 0;
                for (int i = 1, g = -1; i < n; i++) {
                    if ((i & (i - 1)) == 0) g++;
                    dp[i] = dp[i ^ (1 << g)] ^ (1 << (k - 1 - g));
                }
                wR[1] = 1;
                wI[1] = 0;
                for (int t = 0; t < k - 1; t++) {
                    double a = Math.PI / n * (1 << (k - 1 - t));
                    double curR = Math.cos(a), curI = Math.sin(a);
                    int p2 = (1 << t), p3 = p2 * 2;
                    for (int j = p2, k = j * 2; j < p3; j++, k += 2) {
                        wR[k] = wR[j];
                        wI[k] = wI[j];
                        wR[k + 1] = wR[j] * curR - wI[j] * curI;
                        wI[k + 1] = wR[j] * curI + wI[j] * curR;
                    }
                }
            }
            for (int i = 0; i < n; i++) {
                int d = dp[i];
                if (i < d) {
                    double tmp = aR[i];
                    aR[i] = aR[d];
                    aR[d] = tmp;
                    tmp = aI[i];
                    aI[i] = aI[d];
                    aI[d] = tmp;
                }
            }
            if (inv) for (int i = 0; i < n; i++) aI[i] = -aI[i];
            for (int len = 1; len < n; len <<= 1) {
                for (int i = 0; i < n; i += len) {
                    int wit = len;
                    for (int it = 0, j = i + len; it < len; it++, i++, j++) {
                        double tmpR = aR[j] * wR[wit] - aI[j] * wI[wit];
                        double tmpI = aR[j] * wI[wit] + aI[j] * wR[wit];
                        wit++;
                        aR[j] = aR[i] - tmpR;
                        aI[j] = aI[i] - tmpI;
                        aR[i] += tmpR;
                        aI[i] += tmpI;
                    }
                }
            }
        }

        static long[] multiply(long[] a, long[] b) {
            int na = a.length, nb = b.length;
            for (k = 0, n = 1; n < na + nb - 1; n <<= 1, k++) {}
            for (int i = 0; i < n; ++i) {
                aR[i] = i < na ? a[i] : 0;
                aI[i] = i < nb ? b[i] : 0;
            }
            fft(false);
            aR[n] = aR[0];
            aI[n] = aI[0];
            double q = -1.0 / n / 4.0;
            for (int i = 0; i <= n - i; ++i) {
                double tmpR = aR[i] * aR[i] - aI[i] * aI[i];
                double tmpI = aR[i] * aI[i] * 2;
                tmpR -= aR[n - i] * aR[n - i] - aI[n - i] * aI[n - i];
                tmpI -= aR[n - i] * aI[n - i] * -2;
                aR[i] = -tmpI * q;
                aI[i] = tmpR * q;
                aR[n - i] = aR[i];
                aI[n - i] = -aI[i];
            }
            fft(true);
            long[] ans = new long[n = na + nb - 1]; // ONLY MOD IF NEEDED
            for (int i = 0; i < n; i++) ans[i] = Math.round(aR[i]) % MOD;
            return ans;
        }
        static void fft2(double[][] xr, double[][] xi, boolean inv) {
            n = xr[0].length;
            k = Integer.numberOfTrailingZeros(n);
            for (int i = 0; i < xr.length; i++) {
                for (int j = 0; j < n; j++) { aR[j] = xr[i][j];  aI[j] = xi[i][j]; }
                fft(inv);
                for (int j=0;j<n;j++){xr[i][j] = aR[j] / (inv ? n : 1);  xi[i][j] = aI[j] / (inv ? -n : 1);}
            }
            n = xr.length;
            k = Integer.numberOfTrailingZeros(n);
            for (int j = 0; j < xr[0].length; j++) {
                for (int i = 0; i < n; i++) { aR[i] = xr[i][j];  aI[i] = xi[i][j]; }
                fft(inv);
                for (int i=0;i<n;i++){xr[i][j] = aR[i] / (inv ? n : 1);  xi[i][j] = aI[i] / (inv ? -n : 1);}
            }
        }
        static long[][] multiply2(long[][] a, long[][] b) {
            int n1, n2;
            for (n1 = 1; n1 < a.length + b.length - 1; n1 <<= 1) {}
            for (n2 = 1; n2 < a[0].length + b[0].length - 1; n2 <<= 1) {}
            double[][] ar = new double[n1][n2], ai = new double[n1][n2];
            double[][] br = new double[n1][n2], bi = new double[n1][n2];
            for (int i = 0; i < a.length; i++) for(int j=0;j<a[i].length;j++) ar[i][j] = a[i][j];
            for (int i = 0; i < b.length; i++) for(int j=0;j<b[i].length;j++) br[i][j] = b[i][j];
            fft2(ar,ai,false); fft2(br,bi,false);
            for (int i = 0; i < n1; i++) {
                for(int j = 0; j < n2; j++) {
                    double r1 = ar[i][j], r2 = br[i][j];
                    double i1 = ai[i][j], i2 = bi[i][j];
                    double real = r1 * r2 - i1 * i2;
                    ai[i][j] = i1 * r2+ i2*r1;
                    ar[i][j] = real;
                }
            }
            fft2(ar,ai,true);  long[][] result = new long[n1=a.length+b.length-1][n2=a[0].length+b[0].length-1];
            for (int i = 0; i < n1; i++)
                for(int j = 0; j < n2; j++) result[i][j] = Math.round(ar[i][j]);
            return result;
        }
        //#
        static long[] multiplyPrecise(long[] a, long[] b) {
            long k = (long)(Math.sqrt(MOD));
            long[] a1 = new long[a.length], a2 = new long[a.length];
            long[] b1 = new long[b.length], b2 = new long[b.length];
            for(int i=0;i<a.length;i++) {
                a1[i] = a[i] % k;
                a2[i] = a[i] / k;
            }
            for(int i=0;i<b.length;i++) {
                b1[i] = b[i] % k;
                b2[i] = b[i] / k;
            }
            long[] r11 = multiply(a1, b1), r12 = multiply(a1, b2), r21 = multiply(a2, b1), r22 = multiply(a2, b2);
            long[] res = new long[r11.length];
            for(int i=0;i<res.length;i++)
                res[i] = (k*k*r22[i] + k*(r12[i] + r21[i]) + r11[i]) % MOD;
            return res;
        }
        //$
        //#
        static long[] multiplyOr(long[] eq1, long[] eq2) {
            int n = Math.max(eq1.length, eq2.length);
            if((n & (n-1)) != 0)
                n = Integer.highestOneBit(n)*2;
            eq1 = fftOr(eq1, n, false);
            eq2 = fftOr(eq2, n, false);
            for(int i=0;i<eq1.length;i++)
                eq1[i] *= eq2[i];
            eq1 = fftOr(eq1, n, true);
            return eq1;
        }
        //$
        // To use: FFT both, product, iFFT (n is next power of 2)
        static long[] fftOr(long[] arr, int n, boolean invert) {
            long[] ans = Arrays.copyOf(arr, n);
            for (int b = 1; b < n; b <<= 1)
                for (int i = 0; i < n; i++) {
                    if ((i & b) != 0) continue;
                    ans[i + b] += invert ? -ans[i] : ans[i];
                }
            return ans;
        }
        static long[] fftXor(long[] arr, int n, boolean invert) {
            long[] ans = Arrays.copyOf(arr, n);
            for (int b = 1; b < n; b <<= 1)
                for (int i = 0; i < n; i++) {
                    if((i & b) != 0) continue;
                    long u = ans[i], v = ans[i+b];
                    ans[i] = u + v;  ans[i + b] = u - v;
                }
            if (invert) for (int i = 0; i < n; i++) ans[i] /= n;
            return ans;
        }
    }

}


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

/**
 * Copyright (c) 2013 Andrew Shulayev
 */
public class NearestFraction {

    BufferedReader br;
    StringTokenizer st;
    PrintWriter out;

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

    long gcd(long a, long b) {
        if (b == 0) return a;
        return gcd(b, a % b);
    }

    int

    class Fraction implements Comparable<Fraction> {
        long numer, denom;

        public Fraction(long numer, long denom) {
            long g = gcd(numer, denom);
            this.numer = numer / g;
            this.denom = denom / g;
        }

        public Fraction next(Fraction other) {
            return new Fraction(this.numer + other.numer, this.denom + other.denom);
        }

        public int compareTo(Fraction other) {
            long x1 = (long) this.numer * (long) other.denom;
            long x2 = (long) this.denom * (long) other.numer;

            return Long.compare(x1, x2);
        }

        public Fraction minus(Fraction other) {
            return new Fraction(this.numer * other.denom - this.denom * other.numer, this.denom * other.denom);
        }
    }

    void run() throws IOException {
        br = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);

        int x = nextInt();
        int y = nextInt();
        int n = nextInt();

        int m = x / y;
        Fraction needle = new Fraction(x - m * y, y);

        Fraction left = new Fraction(0, 1);
        Fraction right = new Fraction(1, 1);

        Fraction result = null;

        while (true) {
            Fraction next = left.next(right);

            if (next.denom > n) {
                // must choose between left and right
                Fraction l1 = needle.minus(left);
                Fraction l2 = right.minus(needle);

                if (l1.compareTo(l2) <= 0) {
                    result = left;
                } else {
                    result = right;
                }
                break;
            }

            int res = next.compareTo(needle);
            if (res == 0) {
                result = next;
                break;
            } else if (res > 0) {
                right = next;
            } else {
                left = next;
            }
        }

        out.printf("%d/%d\n", result.numer + result.denom * m, result.denom);

        out.close();
    }

    String next() throws IOException {
        while (st == null || !st.hasMoreTokens()) {
            st = new StringTokenizer(br.readLine());
        }
        return st.nextToken();
    }

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


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

public class B {

	//int INF = 1 << 28;
	long INF = 1L << 62;
	double EPS = 1e-10;

	void run() {
		Scanner sc = new Scanner(System.in);
		long x = sc.nextLong(), y = sc.nextLong();
		int n = sc.nextInt();

		P tar = new P(x, y);
		P cmp = new P(INF, 1), ans = new P(-1, -1);
		for(int b=1;b<=n;b++) {
			long sa = tar.x / tar.y * b + 1, a = INF;
			long v = INF;
			for(long i=sa-1;i<=sa+1;i++) if(v > abs(tar.x*b - i*tar.y)){
				a = i;
				v = abs(tar.x*b - i*tar.y);
//				debug("", a, b);
			}
			P tmp = new P( v, tar.y * b );
			if(cmp.compareTo(tmp)>0) {
				cmp = tmp;
				ans = new P(a, b);
			}
//			debug(a, v, b);
		}
		System.out.println(ans);
	}

	class P implements Comparable<P>{
		long x, y;
		P(long x, long y) {
			this.x = x;
			this.y = y;
		}
		@Override
		public int compareTo(P p) {
			// TODO 自動生成されたメソッド・スタブ
			return x * p.y - p.x * y>0? 1: -1;
		}

		public String toString() {
			return x + "/" + y;

		}
	}

	void debug(Object... os) {
		System.err.println(Arrays.deepToString(os));
	}

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


public class B {

    public static void main(String[] args) {
        Scanner in = new Scanner();
        int x = in.nextInt();
        int y = in.nextInt();
        int n = in.nextInt();
        long a = n;
        long b = n;
        double cur = 100000;
        double val = (double) x / y;
        //System.out.println(val);
        for (long i = 1; i <= n; i++) {
            long j = x * i / y;
            double temp = (double) j / i;
            double dif = Math.abs(temp - val) - Math.abs(cur - val);
            //System.out.println(temp + " " + cur + " " + dif);
            if (dif < 0 && Math.abs(dif) > 1e-15) {
                cur = temp;
                //  System.out.println(1e7);
                a = j;
                b = i;
            }
            j++;
            temp = (double) j / i;
            dif = Math.abs(temp - val) - Math.abs(cur - val);
            //System.out.println(dif + " " + 1e-6);
            if (dif < 0 && Math.abs(dif) > 1e-15) {
                cur = temp;
                a = j;
                b = i;
            }
        }
        System.out.println(a + "/" + b);

    }

    static class Scanner {

        BufferedReader br;
        StringTokenizer st;

        public Scanner() {
            //System.setOut(new PrintStream(new BufferedOutputStream(System.out), true));
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        public String next() {

            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (Exception e) {
                    throw new RuntimeException();
                }
            }
            return st.nextToken();
        }

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

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

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

        public String nextLine() {
            st = null;
            try {
                return br.readLine();
            } catch (Exception e) {
                throw new RuntimeException();
            }
        }

        public boolean endLine() {
            try {
                String next = br.readLine();
                while (next != null && next.trim().isEmpty()) {
                    next = br.readLine();
                }
                if (next == null) {
                    return true;
                }
                st = new StringTokenizer(next);
                return st.hasMoreTokens();
            } catch (Exception e) {
                throw new RuntimeException();
            }
        }
    }
}


import java.util.Scanner;
import java.io.OutputStream;
import java.io.IOException;
import java.io.PrintWriter;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 * @author MrX
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		Scanner in = new Scanner(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
        int a, b, n;
        a = in.nextInt();
        b = in.nextInt();
        n = in.nextInt();

        if (n >= b) {
            out.printf("%d/%d", a, b);
        } else {
            int bestx = 0, besty = 0;
            double bestdiff = 1000000;
            for (int y = n; y > 0; y--) {
                int x = a*y/b;
                if (abs((double)(a * y - b * x)) < bestdiff) {
                    bestdiff = abs((double)(a * y - b * x));
                    bestx = x; besty = y;
                }
            }

            out.printf("%d/%d", bestx, besty);
        }		out.close();
	}
}


import java.util.*;
import java.math.*;
public class tester
{
    public static void main(String a[])
    {
        Scanner s=new Scanner(System.in);
        int n=s.nextInt(),c=0;
        HashMap<String> h=new HashMap<String>();
        for(int j=1;j<=n;j++)
        {
            for(int k=j+1;k<=n;k++)
            {
                int x=j^k;

                if(x<=n && j+k>=x && j+x>=k && k+x>=j)
                {
                      int a[]=new int[3];
                a[0]=j;
                a[1]=k;
                a[2]=x;
                Arrays.sort(a);
                String st="";
                for(int i=1;i<=3;i++)
                {
                    st=st+Integer.toString(a[i])+" ";
                }
                if(!h.containsKey(st))
                {
                    h.put(st,0);
                    c++;
                }

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


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

      int a,b,c,n;
      int x=0;
      n=sc.nextInt();
      for ( a = 1; a<= n; a++) {
        for ( b = a; b <= n; b++) {
           for(c=b;c<=n;c++)
              {
            if ((a^b^c)==0 )
                x++;
        }}}
        System.out.printf(x);
    }
    }


import java.util.*;
import java.math.*;
public class tester
{
    public static void main(String a[])
    {
        Scanner s=new Scanner(System.in);
        int n=s.nextInt(),c=0;
        HashMap<String> h=new HashMap<String>();
        for(int j=1;j<=n;j++)
        {
            for(int k=j+1;k<=n;k++)
            {
                int x=j^k;

                if(x<=n && j+k>=x && j+x>=k && k+x>=j)
                {
                      int a[]=new int[3];
                a[0]=j;
                a[1]=k;
                a[2]=x;
                Arrays.sort(a);
                String st="";
                for(int i=1;i<=3;i++)
                {
                    st=st+Integer.toString(a[i])+"";
                }
                if(!h.containsKey(st))
                {
                    h.put(st,0);
                    c++;
                }

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


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

      int a,b,n;
      int x=0;
      n=sc.nextInt();
      for ( a = 1; a<= n; a++) {
        for ( b = a; b <= n; b++) {
          int c=a^b;
          if (a+b>c && c<=n) {
					x++;

          }}}
        System.out.printf(x);
    }
    }


import java.util.*;
import java.lang.*;
import java.io.*;
public class A
{
    public static void main(String args[])throws IOException
    {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        int n,i,j,count,k;
        String t=br.readLine();
        n=Integer.parseInt(t);
        t=br.readLine();
        char[] s=t.toCharArray();
        k=0;
        for(i=0;i<n;)
        {
            if(s[i]=='x')
            {
                c=1;
                for(j=i+1;j<n;j++)
                {
                    if(s[j]=='x')
                    c=c+1;
                    else
                    break;
                }
                i=i+c;
                if(c!=1)
                k=k+(c-2);
            }
            else
            i=i+1;
        }
        System.out.pritln(k);
    }
}


import java.io.File;
import java.io.FileNotFoundException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class A978 {
	public static void main(String[] args) throws FileNotFoundException {

		Scanner scan = new Scanner(System.in);
		int n = Integer.parseInt(scan.nextLine());
		String str = scan.nextLine();
		int bo = 0;
		for(int i = 0; i < n; i ++){
		    if(str.charAt(i)=='x'){
		        bo++;
		    }
		}
		if(bo == n){
		    System.out.println(n - 2);
		    System.exit(0);
		}
		s =   str + "i";
	//	System.out.println(s);
		char[] bar = s.toCharArray();
		ArrayList<Integer> non_x = new ArrayList<Integer>();

		int x =0;
		for(int i =0 ; i < n+1; i++) {
			if(bar[i] != 'x') {
				non_x.add(i);
			}
		}

		int counter = 0;

	//	System.out.println(non_x);

		ArrayList<Integer> arr = new ArrayList<Integer>();
		for(int i =0 ; i < non_x.size()-1; i ++) {
			arr.add(non_x.get(i+1)- non_x.get(i));
		}

		if(non_x.get(0)> 2) {

			counter += non_x.get(0)-2;
		}
		for(int i =1 ; i < arr.size(); i ++) {
			if(arr.get(i)>2) {
				counter += arr.get(i)-2;

			}
		}
		System.out.println(counter);

	}

}


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

public class Filename {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner s = new Scanner(System.in);
		int n = s.nextInt();
		String str = s.next();
		int[] count = new int[26];
		ArrayList<Character> ll = new ArrayList<>();
		if (!str.contains("xxx")) {
			System.out.println(0);
			return;
		}
		int c = 0;
		for (int i = 0; i < n - 2; i++) {

			if (str.charAt(i) == 'x') {
				count['x' - 'a']++;

				if (count['x' - 'a'] == 3) {
					c++;
					count['x' - 'a']--;

				}
			}

			else {
				count['x' - 'a'] = 0;
			}

		}
		System.out.println(c);


import java.util.*;
import java.util.Scanner;

public class Test
{
    public static void main(String args[])
    {
        int n;
        Scanner sc = new Scanner(System.in);
        n = sc.nextInt();
        String s = sc.next();
        String u = new String("xxx");
        int count = 0;
        while(s.indexOf(u) != -1)
        {
        int x = s.indexOf(u);
        count++;
        s = s.substring(0, x) + s.substring(x + 1);
        }
        System.out.println(count);
}


import static java.lang.System.err;
import static java.lang.System.out;
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.StringReader;
import java.lang.reflect.Array;
import java.util.NoSuchElementException;
import java.util.StringTokenizer;
import static adnap9.contests.cf.Utils.*;

public class A {

    public static void main(String[] args) {
        FastReader fr = new FastReader();
        int n = fr.nextInt();
        Integer[] t = fr.nextIntArray(n);
        int min = 0, max = n-1;
        for (int i = 0; i < n; i++) {
            if (t[i] < t[min]) min = i;
            if (t[i] > t[max]) max = i;
        }
        swap(t,0,max);
        swap(t,n-1,min);
        pr.printArray(t, " ");
        fr.close();
    }
}

class Printer {
    public Printer() {
    }
    public void println(String s) {
        out.println(s);
    }
    public void print(String s) {
        out.print(s);
    }
    public void ePrintln(String s) {
        err.println(s);
    }
    public void ePrint(String s) {
        err.print(s);
    }
    public <T> void printArray(T[] t) {
        for (T e : t) {
            println(e.toString());
        }
    }
    public <T> void printArray(T[] t, String sep) {
        for (T e : t) {
            print(e.toString() + sep);
        }
    }
    public <T> void ePrintArray(T[] t) {
        for (T e : t) {
            ePrintln(e.toString());
        }
    }
}
class FastReader extends CloseableTextParser {
    private StringTokenizer st;
    private BufferedReader br;
    private boolean isNext = true;
    private boolean closed = false;

    /***************/
    public FastReader() {
        br = new BufferedReader(new InputStreamReader(System.in));
        // prepareTokenizer();
    }
    public FastReader(BufferedReader br) {
        this.br = br;
        // prepareTokenizer();
    }
    public FastReader(String s) {
        br = new BufferedReader(new StringReader(s));
        // prepareTokenizer();
    }
    /*******************/
    private void prepareTokenizer() {
        while (isNext == true && (st == null || !st.hasMoreTokens())) {
            try {
                String str = br.readLine();
                if (str == null) {
                    isNext = false;
                    st = null;
                } else {
                    st = new StringTokenizer(str);
                }
            } catch (IOException e) {
                e.printStackTrace();
                throw new RuntimeException(e);
            }
        }
    }
    private String nextToken(String delim) {
        if (closed) throw new IllegalStateException();
        prepareTokenizer();
        if (!isNext) throw new NoSuchElementException();
        String str = (delim != null) ? (st.nextToken(delim)) : (st.nextToken());
        // prepareTokenizer();
        return str;
    }
    private String nextToken() {
        return nextToken(null);
    }
    /*********************/
    public void close() {
        if (closed) throw new IllegalStateException();
        try {
            br.close();
            closed = true;
        } catch (IOException e) {
            e.printStackTrace();
            throw new RuntimeException(e);
        }
    }
    public boolean hasNext() {
        return true;
    }
    /******************************/
    public String next() {
        return nextToken();
    }
    public String next(String delim) {
        return nextToken(delim);
    }
    public String nextLine() {
        return nextToken("\n");
    }
    public int nextInt() {
        return Integer.parseInt(nextToken());
    }
    public long nextLong() {
        return Long.parseLong(nextToken());
    }
    public double nextDouble() {
        return Double.parseDouble(nextToken());
    }
    public char nextChar() throws UnsupportedOperationException {
        throw new UnsupportedOperationException();
    }
    public byte nextByte() {
        return Byte.parseByte(nextToken());
    }
    public short nextShort() {
        return Short.parseShort(nextToken());
    }
    public boolean nextBoolean() {
        return Boolean.parseBoolean(nextToken());
    }
}
class Utils {
    public static <T extends Object> void fill2d(T[][] t, T el) {
        for (T[] t2 : t) {
            for (int i = 0; i < t2.length; i++) {
                t2[i] = el;
            }
        }
    }
    @SuppressWarnings("unchecked")
    public static <T> T[][] new2dArray(Class<T> c, int sx, int sy) {
        return (T[][]) Array.newInstance(c, sx, sy);
    }
    public static String merge(String[] st) {
        StringBuilder sb = new StringBuilder("");
        for (String s : st)
            sb.append(s);
        return sb.toString();
    }

    public static <T> void swap(T[] t, int p1, int p2) {
        T a = t[p1];
        t[p1] = t[p2];
        t[p2] = a;
    }

    public final static Printer pr = new Printer();

    private Utils() {
    }
}
abstract class CloseableTextParser extends ScannerLike implements Closeable, AutoCloseable {}
abstract class ScannerLike {
    public Integer[] nextIntArray(int n) {
        Integer[] t = new Integer[n];
        for (int i = 0; i < t.length; i++) {
            t[i] = nextInt();
        }
        return t;
    }
    public Long[] nextLongArray(int n) {
        Long[] t = new Long[n];
        for (int i = 0; i < t.length; i++) {
            t[i] = nextLong();
        }
        return t;
    }
    public Short[] nextShortArray(int n) {
        Short[] t = new Short[n];
        for (int i = 0; i < t.length; i++) {
            t[i] = nextShort();
        }
        return t;
    }
    public Byte[] nextByteArray(int n) {
        Byte[] t = new Byte[n];
        for (int i = 0; i < t.length; i++) {
            t[i] = nextByte();
        }
        return t;
    }
    public Boolean[] nextBooleanArray(int n) {
        Boolean[] t = new Boolean[n];
        for (int i = 0; i < t.length; i++) {
            t[i] = nextBoolean();
        }
        return t;
    }
    public String[] nextStringArray(int n, String delim) {
        String[] t = new String[n];
        for (int i = 0; i < t.length; i++) {
            t[i] = (delim != null) ? (next(delim)) : (next());
        }
        return t;
    }
    public String[] nextStringArray(int n) {
        return nextStringArray(n, null);
    }
    /*
     * public <T> T next(ObjectReaderFromText<T> p) { return p.loadFromInput(this); }
     */
    public abstract String next();
    public abstract boolean hasNext();
    public abstract byte nextByte();
    public abstract short nextShort();
    public abstract int nextInt();
    public abstract long nextLong();
    public abstract boolean nextBoolean();
    public abstract String nextLine();
    public abstract String next(String delim);
}


import java.util.*;

public class Difference {
  public static void main(String[] args) {
    Scanner in = new Scanner(System.in);
    int n = in.nextInt();
    ArrayList<Integer> list = new ArrayList();
    for(int i = 0; i < n; i++) {
      list.add(in.nextInt());
    }
    Collections.sort(list);
    System.out.print(list.get(n-1));
    for(int i = 1; i < n - 1 0; i++) System.out.print (list.get(i) + " ");
    System.out.print(list.get(0);
  }
}


import java.util.*;
public class tatti{

          public static void main(String dsgs[]){
                    Scanner s = new Scanner(System.in);
                    int n;
                    n = s.nextInt();
                    int a[] =new int[n];
                    for(int i=0;i<n;i++){
                              a[i] = s.nextInt();
                    }
                    int max =Integer.MAX_VALUE;
                    int x=0;y=0;
                    for(int i=0;i<n;i++){
                              for(int j=i+1;j<n;j++){
                                        if(max<(a[i]-a[j])){
                                                  x = i;
                                                  y = j;
                                                  max = a[i]-a[j];
                                        }
                              }
                    }
                    int temp = a[x];
                    a[x] = a[0];
                    a[0] = temp;
                    temp = a[n-1];
                    a[n-1] = a[y];
                    a[y] = temp;
                    Arrays.sort(a,1,n-1);
                    for(int i=0;i<n;i++)
                              System.out.println(a[i]+" ");
          }
}


import java.util.*;

public class Difference {
  public static void main(String[] args) {
    Scanner in = new Scanner(System.in);
    int n = in.nextInt();
    ArrayList<Integer> list = new ArrayList();
    for(int i = 0; i < n; i++) {
      list.add(in.nextInt());
    }
    Collections.sort(list);
    System.out.print(list.get(n-1)+ " ");
    for(int i = 1; i < n - 1 0; i++) System.out.print(list.get(i) + " ");
    System.out.print(list.get(0));
  }
}


import java.util.*;
import java.Math.BigInteger;

public class Solution{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        BigInteger n = new BigInteger(""+sc.nextInt());
        BigInteger temp = n.add(BigInteger.valueOf(1));
        n = n.multiply(temp);
        n = n.multiply(BigInteger.valueOf(3));
        n = n.add(BigInteger.valueOf(1));
        System.out.println(n);
    }
}


import java.util.*;
import java.util.regex.*;
import java.lang.*;
public class Main{
	public static void main(String[] args)
	{
	Scanner sc=new Scanner(System.in);
	long n=sc.nextLone();
	System.out.println(6+(n-1)*(n+10)/2);

	}

}


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

public class sssss {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String s = br.readLine();
		long x =Long.parseLong(s);
		long ans=1;

        ans+=1l*n*(n+1)*3;

        System.out.println(ans);
	}
}


import java.io.*;
import java.math.*;
public class hexagon
{
 public static void main(String args[])throws IOException
 {
  InputStreamReader read=new InputStreamReader(System.in);
  BufferedReader in=new BufferedReader(read);
  int n;
  n=Integer.parseInt(in.readLine());
  BigInteger s=BigInteger.valueOf(n);
  s=s.multiply(BigIneteger.valueOf(n+1));
  s=s.divide(new BigInteger("2"));
  s=s.multiply(new BigInteger("6");
  s=s.add(new BigInteger("1");
  System.out.println(s);
 }
}


public class Main {
 public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
        int k = sc.nextInt();
        StringBuilder line = new StringBuilder();

        for (int i = 0; i <= 2800; i++)
            line.append(i);

        System.out.print(line.charAt(k));
    }
}


import java.util.*;
public class digits
{
public static void main(String args[])
{
Scanner obj=new Scanner(System.in);
int n;
String s;
char c;
n=obj.nextInt();
for(int i=1;i<=n;i++)
{
s=s+String(i);
}
c=s.charAt(n-1);
System.out.println(c);
}
}


public class DigitsSequence {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        System.out.println(find(scanner.nextInt()));

    }

    static int find(int index){
        int i = 1;
        int len = 9;
        int max = 9;
        while(len < index){
            int tmp = 9 * (int) Math.pow(10, i);
            i++;
            len += i * tmp;
            max += tmp;
        }
        int diff = len - index;
        int laterCount = diff / i;
        int remainder = diff % i;
        int current = max - laterCount;
        int k = i - 1 - remainder;
        return Integer.parseInt(String.valueOf(current).substring(k, k+1));
    }
}


public class Main {

    public static void main(String[] args) {

       Scanner sc = new Scanner(System.in);
        int k = sc.nextInt();
        StringBuilder line = new StringBuilder();

        for (int i = 0; i <= 2800; i++)
            line.append(i);

        System.out.print(line.charAt(k));

    }
}


mport java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int x1 = scan.nextInt();
        int y1 = scan.nextInt();
        int x2 = scan.nextInt();
        int y2 = scan.nextInt();
        int x3 = scan.nextInt();
        int y3 = scan.nextInt();

        if (isTriangle(x1, y1, x2, y2, x3, y3)) {
            System.out.println("RIGHT");
        } else if (isTriangle(x1 + 1, y1, x2, y2, x3, y3)) {
            System.out.println("ALMOST");
        } else if (isTriangle(x1 - 1, y1, x2, y2, x3, y3)) {
            System.out.println("ALMOST");
        } else if (isTriangle(x1, y1 + 1, x2, y2, x3, y3)) {
            System.out.println("ALMOST");
        } else if (isTriangle(x1, y1 - 1, x2, y2, x3, y3)) {
            System.out.println("ALMOST");
        } else if (isTriangle(x1, y1, x2 + 1, y2, x3, y3)) {
            System.out.println("ALMOST");
        } else if (isTriangle(x1, y1, x2 - 1, y2, x3, y3)) {
            System.out.println("ALMOST");
        } else if (isTriangle(x1, y1, x2, y2 + 1, x3, y3)) {
            System.out.println("ALMOST");
        } else if (isTriangle(x1, y1, x2, y2 - 1, x3, y3)) {
            System.out.println("ALMOST");
        } else if (isTriangle(x1, y1, x2, y2, x3 + 1, y3)) {
            System.out.println("ALMOST");
        } else if (isTriangle(x1, y1, x2, y2, x3 - 1, y3)) {
            System.out.println("ALMOST");
        } else if (isTriangle(x1, y1, x2, y2, x3, y3 + 1)) {
            System.out.println("ALMOST");
        } else if (isTriangle(x1, y1, x2, y2, x3, y3 - 1)) {
            System.out.println("ALMOST");
        } else {
            System.out.println("NEITHER");
        }

    }

    public static double getLength(int x1, int y1, int x2, int y2) {
        int x = Math.max(x1, x2) - Math.min(x1, x2);
        int y = Math.max(y1, y2) - Math.min(y1, y2);
        return Math.sqrt((double) x * x + y * y);
    }

    public static boolean isTriangle(int x1, int y1, int x2, int y2, int x3, int y3) {
        if(valid(x1,y1,x2,y2))
            return false;
        if(valid(x2,y2,x3,y3))
            return false;
        if(valid(x3,y3,x1,y1))
            return false;
        double a = getLength(x1, y1, x2, y2);
        double b = getLength(x2, y2, x3, y3);
        double c = getLength(x3, y3, x1, y1);
        if (Math.sqrt(a * a + b * b) - c >= -.01 && Math.sqrt(a * a + b * b) - c <= .01) {
            return true;
        }
        if (Math.sqrt(a * a + c * c) - b >= -.01 && Math.sqrt(a * a + c * c) - b <= .01) {
            return true;
        }
        if (Math.sqrt(c * c + b * b) - a >= -.01 && Math.sqrt(c * c + b * b) - a <= .01) {
            return true;
        }
        return false;
    }

    public static boolean valid(int x1, int y1, int x2, int y2){
        if(x1==x2 && y1==y2)
            return true;
        return false;
    }
}


import java.awt.Point;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
import javafx.util.Pair;

/*
 * 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 TriangleP2 {
    public static boolean reight(double x1,double y1,double x2,double y2,double x3,double y3)
    {
//        double m1=((double)p1.getY()-(double)p2.getY());
//        if(((double)p1.getX()-(double)p2.getX())==0)
//            m1=-1;
//        else
//            m1/=((double)p1.getX()-(double)p2.getX());
//        double m2=((double)p1.getY()-(double)p3.getY());
//        if(((double)p1.getX()-(double)p3.getX())==0)
//            m2=-1;
//        else
//            m2/=((double)p1.getX()-(double)p3.getX());
//        double m3=((double)p2.getY()-(double)p3.getY());
//        if(((double)p2.getX()-(double)p3.getX())==0)
//            m3=-1;
//        else
//            m3/=((double)p2.getX()-(double)p3.getX());
//        if((m1==0||m2==0||m3==0)&&(m1==-1||m2==-1||m3==-1))
//            return true;
//        return false;
        double d1=(x1-x2)*(x1-x2)+(y1-y2)*(y1-y2);
        double d2=(x1-x3)*(x1-x3)+(y1-y3)*(y1-y3);
        double d3=(x2-x3)*(x2-x3)+(y2-y3)*(y2-y3);
        if(d1==d2+d3||d2==d1+d3||d3==d1+d2)
            return true;
        return false;
    }
    public static void main(String[] args)
    {
        MyScanner scan=new MyScanner();
        double x1=scan.nextDouble();
        double y1=scan.nextDouble();
        double x2=scan.nextDouble();
        double y2=scan.nextDouble();
        double x3=scan.nextDouble();
        double y3=scan.nextDouble();

        if (reight(x1,y1,x2,y2,x3,y3))
        {
            System.out.println("RIGHT");
            return;
        }
        double k=x1;
        double h=y1;
        if(reight(k+1,h,x2,y2,x3,y3))
        {
            System.out.println("ALMOST");
            return;
        }
        if(reight(k-1,h,x2,y2,x3,y3))
        {
            System.out.println("ALMOST");
            return;
        }
        if(reight(k,h+1,x2,y2,x3,y3))
        {
            System.out.println("ALMOST");
            return;
        }
        if(reight(k,h-1,x2,y2,x3,y3))
        {
            System.out.println("ALMOST");
            return;
        }
        k=x2;
        h=y2;
        if(reight(x1,y1,k+1,h,x3,y3))
        {
            System.out.println("ALMOST");
            return;
        }
        if(reight(x1,y1,k-1,h,x3,y3))
        {
            System.out.println("ALMOST");
            return;
        }
        if(reight(x1,y1,k,h+1,x3,y3))
        {
            System.out.println("ALMOST");
            return;
        }
        if(reight(x1,y1,k,h-1,x3,y3))
        {
            System.out.println("ALMOST");
            return;
        }
        k=x3;
        h=y3;
        if(reight(x1,y1,x2,y2,k+1,h))
        {
            System.out.println("ALMOST");
            return;
        }
        if(reight(x1,y1,x2,y2,k-1,h))
        {
            System.out.println("ALMOST");
            return;
        }
        if(reight(x1,y1,x2,y2,k,h+1))
        {
            System.out.println("ALMOST");
            return;
        }
        if(reight(x1,y1,x2,y2,k,h-1))
        {
            System.out.println("ALMOST");
            return;
        }
        System.out.println("NEITHER");
    }
}
class MyScanner
{
    static BufferedReader br;
    static StringTokenizer st;

    public MyScanner()
    {
        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());
    }
}


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

public class triangle
{
    public static void main(String[] qqqqadhwiRIZZO_LOVES_BOYS) throws Throwable
    {
        BufferedReader in=new BufferedReader(new InputStreamReader(System.in));
        int[] points=new int[6];
        String[] sa=in.readLine().split("\\s+");
        for(int i=0;i<6;i++)
            points[i]=Integer.parseInt(sa[i]);
        if(isRight(points))
        {
            System.out.println("RIGHT");
            return;
        }
        for(int i=0;i<6;i++)
        {
            points[i]--;
            if(isRight(points))
            {
                System.out.println("ALMOST");
                return;
            }
            points[i]+=2;
            if(isRight(points))
            {
                System.out.println("ALMOST");
                return;
            }
        }
        System.out.println("NEITHER");

    }
    static boolean hasArea(int[] points)
    {
        double a=Math.sqrt((points[0]-points[2])*(points[0]-points[2])
            +(points[1]-points[3])*(points[1]-points[3])),
            b=Math.sqrt((points[0]-points[4])*(points[0]-points[4])
            +(points[1]-points[5])*(points[1]-points[5])),
            c=Math.sqrt((points[2]-points[4])*(points[2]-points[4])
            +(points[3]-points[5])*(points[3]-points[5]));
        double s=(a+b+c)/2;
        double A=Math.sqrt(s*(s-a)*(s-b)*(s-c));
        return A>.0000000001;
    }
    static boolean isRight(int[] points)
    {
        if(!hasArea(points))
            return false;
        double[] atan2s=new double[3];
        for(int i=0;i<3;i++)
        {
            int dx=points[((i+1)*2)%6]-points[((i)*2)%6];
            int dy=points[(((i+1)*2)+1)%6]-points[(((i)*2)+1)%6];
            atan2s[i]=Math.atan2(dy,dx);
        }
     //   System.out.println(Arrays.toString(atan2s));
        for(int i=0;i<3;i++)
        {
            double angle=atan2s[(i+1)%3]-atan2s[i];
            angle=Math.abs(angle)%(2*Math.PI);
            angle=Math.min(angle,2*Math.PI-angle);
            if(Math.abs(Math.abs(angle*2)-Math.PI)<.0000000001 || )
                return true;
        }
        return false;
    }
}


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

public class A{

    Scanner sc=new Scanner(System.in);

    void run(){
        P[] ps=new P[3];
        for(int i=0;i<3;i++){
            ps[i]=new P();
            ps[i].x=sc.nextInt();
            ps[i].y=sc.nextInt();
        }
        if(isRight(ps)){
            System.out.println("RIGHT");
            return;
        }
        boolean f=false;
        int dx={0,0,-1,1};
        int dy={-1,1,0,0};
        for(int j=0;j<3;j++){
            P p=ps[j];
            for(int i=0;i<4;i++){
                p.x+=dx[i];
                p.y+=dy[i];
                if(isRight(p)){
                    System.out.println("ALMOST");
                    return;
                }

                p.x-=dx[i];
                p.y-=dy[i];
            }
        }
        System.out.println("NEITHER");

    }

    class P{
        int x, y;
        P(int x, int y){
            this.x=x;
            this.y=y;
        }
        P(){
            this(0,0);
        }
    }

    boolean isRight(P[] ps){
        int[] d=new int[3];
        for(int i=0;i<3;i++){
            P p=ps[i];
            P q=ps[(i+1)%3];
            d[i]=(q.x-p.x)*(q.x-p.x)+(q.y-p.y)*(q.y-p.y);
        }
        Arrays.sort(d);
        return d[0]!=0&&d[0]+d[1]==d[2];
    }

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


import java.io.BufferedWriter;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;

public class Test {
  static PrintWriter writer =
      new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
  int R, C;
  long[][] ch = new long[61][61];
  int[] cntA = new int[61], cntB = new int[61];
  long best = Long.MAX_VALUE;
  String str;

  public static void main(String[] args) {
    Test te = new Test();
    te.start();
    writer.flush();
  }

  static int readInt() {
    int ans = 0;
    boolean neg = false;
    try {
      boolean start = false;
      for (int c = 0; (c = System.in.read()) != -1; ) {
        if (c == '-') {
          start = true;
          neg = true;
          continue;
        } else if (c >= '0' && c <= '9') {
          start = true;
          ans = ans * 10 + c - '0';
        } else if (start) break;
      }
    } catch (IOException e) {
    }
    return neg ? -ans : ans;
  }

  static long readLong() {
    long ans = 0;
    boolean neg = false;
    try {
      boolean start = false;
      for (int c = 0; (c = System.in.read()) != -1; ) {
        if (c == '-') {
          start = true;
          neg = true;
          continue;
        } else if (c >= '0' && c <= '9') {
          start = true;
          ans = ans * 10 + c - '0';
        } else if (start) break;
      }
    } catch (IOException e) {
    }
    return neg ? -ans : ans;
  }

  static String readString() {
    StringBuilder b = new StringBuilder();
    try {
      boolean start = false;
      for (int c = 0; (c = System.in.read()) != -1; ) {
        if (Character.isLetterOrDigit(c) || c == '?') {
          start = true;
          b.append((char) c);
        } else if (start) break;
      }
    } catch (IOException e) {
    }
    return b.toString();
  }

  static int readChars(char[] a, int off) {
    int cnt = 0;
    try {
      boolean start = false;
      for (int c = 0; (c = System.in.read()) != -1; ) {
        if (Character.isLetterOrDigit(c)) {
          start = true;
          a[off + cnt++] = (char) c;
        } else if (start) break;
      }
    } catch (IOException e) {
    }
    return cnt;
  }

  void dfs(long x, long y, int v1, int v2) {
    long diff = Math.abs(x - y);
    if (best <= 1 || diff - ch[v1][R] * ch[v2][R] >= best) return;
    if (v1 == R - 1 && v2 == R - 1) {
      if (diff < best) best = diff;
      return;
    }
    if (v1 >= R) {
      long cur = ch[v1][R] - ch[v1 - 1][R];
      long other = ch[v2][R];
      dfs(x, y + cur * other, v1 - 1, v2);
    }
    if (v2 >= R) {
      long cur = ch[v2][R] - ch[v2 - 1][R];
      long other = ch[v1][R];
      dfs(x + cur * other, y, v1, v2-1);
    }
  }

  long solve(long x, long y, int v1, int v2) {
    long diff = Math.abs(x - y);
    if (diff - ch[v1][R] * ch[v2][R] > best) return 0;
    if (v1 < R || v2 < R) {
      if (v1 >= cntA[v1 + v2] && v2 >= cntB[v1 + v2]) {
        int sum = v1 + v2;
        v1 -= cntA[sum];
        v2 -= cntB[sum];
        return ch[v1 + v2][v1];
      }
      return 0;
    }
    long ans = 0;
    char c = str.charAt(v1 + v2 - 1);
    if (c != 'B') {
      long cur = ch[v1][R] - ch[v1 - 1][R];
      long other = ch[v2][R];
      ans += solve(x, y + cur * other, v1 - 1, v2);
    }
    if (c != 'A') {
      long cur = ch[v2][R] - ch[v2 - 1][R];
      long other = ch[v1][R];
      ans += solve(x + cur * other, y, v1, v2 - 1);
    }
    return ans;
  }

  void start() {
    R = readInt();
    C = readInt();
    for (int i = 0; i <= 2*(R + C); i++)
      for (int j = 0; j <= i; j++)
        if (j == 0 || j == i) ch[i][j] = 1;
        else ch[i][j] = ch[i - 1][j - 1] + ch[i - 1][j];
    long x = 0, y = 0;
    int v1 = R + C, v2 = R + C;
    while (v1 >= R && v2 >= R)
      if (x > y) {
        long cur = ch[v1][R] - ch[v1 - 1][R];
        long other = ch[v2][R];
        y += cur * other;
        v1--;
      } else {
        long cur = ch[v2][R] - ch[v2 - 1][R];
        long other = ch[v1][R];
        x += cur * other;
        v2--;
      }
    best = Math.abs(x - y);
    dfs(0, 0, R + C, R + C);
    str = readString();
    for (int i = 0; i < 2 * (R + C); i++) {
      cntA[i + 1] = cntA[i] + (str.charAt(i) == 'A' ? 1 : 0);
      cntB[i + 1] = cntB[i] + (str.charAt(i) == 'B' ? 1 : 0);
    }
    long ans = solve(0, 0, R + C, R + C);
    writer.println(ans);
  }
}


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

public class Test {
    int readInt() {
        int ans = 0;
        boolean neg = false;
        try {
            boolean start = false;
            for (int c = 0; (c = System.in.read()) != -1; ) {
                if (c == '-') {
                    start = true;
                    neg = true;
                    continue;
                } else if (c >= '0' && c <= '9') {
                    start = true;
                    ans = ans * 10 + c - '0';
                } else if (start) break;
            }
        } catch (IOException e) {
        }
        return neg ? -ans : ans;
    }

    int r, c;
    Scanner sca = new Scanner(System.in);
    long[][] C = new long[61][61];
    long best;

    void dfs(long x, long y, int v1, int v2) {
        long d = Math.abs(x - y);
        if (best <= 1 || d - C[v1][r]*C[v2][r] >= best) return;
        if (v1 == r - 1 && v2 == r - 1) {
            if (d < best) best = d;
            return;
        }
        if (v1 >= r) {
            long c1 = C[v1][r] - C[v1-1][r], s2 = C[v2][r];
            dfs(x, y + c1*s2, v1 - 1, v2);
        }
        if (v2 >= r) {
            long s1 = C[v1][r], c2 = C[v2][r] - C[v2-1][r];
            dfs(x + s1*c2, y, v1, v2 - 1);
        }
    }

    int[] cntA = new int[61], cntB = new int[61];
    Map<Long, Long> cache = new HashMap<>();
    char[] cs;

    long solve(long x, long y, int v1, int v2) {
        long k = x*10000 + v1*100  + v2;
        Long v = cache.get(k);
        if (v != null) return v;
        v = 0l;
        long d = Math.abs(x - y);
        if (d - C[v1][r]*C[v2][r] > best) {
            cache.put(k, v);
            return v;
        }
        if (v1 < r || v2 < r) {
            if (v1 >= cntA[v1+v2] && v2 >= cntB[v1+v2]) {
                int sum = v1 + v2;
                v1 -= cntA[sum];
                v2 -= cntB[sum];
                v = C[v1+v2][v1];
                cache.put(k, v);
                return v;
            }
            cache.put(k, v);
            return v;
        }
        long ans = 0;
        char c = cs[v1 + v2 - 1];
        if (c != 'B') {
            long c1 = C[v1][r] - C[v1 - 1][r], s2 = C[v2][r];
            ans += solve(x, y + c1*s2, v1 - 1, v2);
        }
        if (c != 'A') {
            long s1 = C[v1][r], c2 = C[v2][r] - C[v2-1][r];
            ans += solve( x + s1*c2, y, v1, v2 - 1);
        }
        return ans;
    }

    void start() {
        r = sca.nextInt(); c = sca.nextInt(); sca.nextLine();
        cs = sca.nextLine().toCharArray();
        for (int i = 0; i <= 2*(r + c); i++)
            for (int j = 0; j <= 2*(r + c); j++) {
                if (j == 0) C[i][j] = 1;
                else if (i == 0) C[i][j] = 0;
                else C[i][j] = C[i-1][j - 1] + C[i - 1][j];
            }
        int v1 = r + c, v2 = r + c;
        long x = 0, y = 0;
        while (v1 >= r && v2 >= 0) {
            if (x > y) {
                long c1 = C[v1][r] - C[v1 - 1][r], s2 = C[v2][r];
                y += c1*s2;
                v1--;
            } else {
                long s1 = C[v1][r], c2 = C[v2][r] - C[v2-1][r];
                x += s1*c2;
                v2--;
            }
        }
        best = Math.abs(x - y);
        dfs(0, 0, r + c, r + c);
        for (int i = 0; i < 2*(r+c); i++) {
            cntA[i + 1] = cntA[i] + (cs[i] == 'A' ? 1 : 0);
            cntB[i + 1] = cntB[i] + (cs[i] == 'B' ? 1 : 0);
        }
        long ans = solve(0, 0, r + c, r + c);
        System.out.println(ans);
    }

    public static void main(String[] args) {

        new Test().start();

    }
}


import java.io.BufferedWriter;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;

public class Test {
  static PrintWriter writer =
      new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
  int R, C;
  long[][] ch = new long[31][31];
  int[] cntA = new int[61], cntB = new int[61];
  long best = Long.MAX_VALUE;
  String str;

  public static void main(String[] args) {
    Test te = new Test();
    te.start();
    writer.flush();
  }

  static int readInt() {
    int ans = 0;
    boolean neg = false;
    try {
      boolean start = false;
      for (int c = 0; (c = System.in.read()) != -1; ) {
        if (c == '-') {
          start = true;
          neg = true;
          continue;
        } else if (c >= '0' && c <= '9') {
          start = true;
          ans = ans * 10 + c - '0';
        } else if (start) break;
      }
    } catch (IOException e) {
    }
    return neg ? -ans : ans;
  }

  static long readLong() {
    long ans = 0;
    boolean neg = false;
    try {
      boolean start = false;
      for (int c = 0; (c = System.in.read()) != -1; ) {
        if (c == '-') {
          start = true;
          neg = true;
          continue;
        } else if (c >= '0' && c <= '9') {
          start = true;
          ans = ans * 10 + c - '0';
        } else if (start) break;
      }
    } catch (IOException e) {
    }
    return neg ? -ans : ans;
  }

  static String readString() {
    StringBuilder b = new StringBuilder();
    try {
      boolean start = false;
      for (int c = 0; (c = System.in.read()) != -1; ) {
        if (Character.isLetterOrDigit(c) || c == '?') {
          start = true;
          b.append((char) c);
        } else if (start) break;
      }
    } catch (IOException e) {
    }
    return b.toString();
  }

  static int readChars(char[] a, int off) {
    int cnt = 0;
    try {
      boolean start = false;
      for (int c = 0; (c = System.in.read()) != -1; ) {
        if (Character.isLetterOrDigit(c)) {
          start = true;
          a[off + cnt++] = (char) c;
        } else if (start) break;
      }
    } catch (IOException e) {
    }
    return cnt;
  }

  void dfs(long x, long y, int v1, int v2) {
    long diff = Math.abs(x - y);
    if (best <= 1 || diff - ch[v1][R] * ch[v2][R] >= best) return;
    if (v1 == R - 1 && v2 == R - 1) {
      if (diff < best) best = diff;
      return;
    }
    if (v1 >= R) {
      long cur = ch[v1][R] - ch[v1 - 1][R];
      long other = ch[v2][R];
      dfs(x, y + cur * other, v1 - 1, v2);
    }
    if (v2 >= R) {
      long cur = ch[v2][R] - ch[v2 - 1][R];
      long other = ch[v1][R];
      dfs(x + cur * other, y, v1, v2-1);
    }
  }

  long solve(long x, long y, int v1, int v2) {
    long diff = Math.abs(x - y);
    if (diff - ch[v1][R] * ch[v2][R] > best) return 0;
    if (v1 < R || v2 < R) {
      if (v1 >= cntA[v1 + v2] && v2 >= cntB[v1 + v2]) {
        int sum = v1 + v2;
        v1 -= cntA[sum];
        v2 -= cntB[sum];
        return ch[v1 + v2][v1];
      }
      return 0;
    }
    long ans = 0;
    char c = str.charAt(v1 + v2 - 1);
    if (c != 'B') {
      long cur = ch[v1][R] - ch[v1 - 1][R];
      long other = ch[v2][R];
      ans += solve(x, y + cur * other, v1 - 1, v2);
    }
    if (c != 'A') {
      long cur = ch[v2][R] - ch[v2 - 1][R];
      long other = ch[v1][R];
      ans += solve(x + cur * other, y, v1, v2 - 1);
    }
    return ans;
  }

  void start() {
    R = readInt();
    C = readInt();
    for (int i = 0; i <= R + C; i++)
      for (int j = 0; j <= i; j++)
        if (j == 0 || j == i) ch[i][j] = 1;
        else ch[i][j] = ch[i - 1][j - 1] + ch[i - 1][j];
    long x = 0, y = 0;
    int v1 = R + C, v2 = R + C;
    while (v1 >= R && v2 >= R)
      if (x > y) {
        long cur = ch[v1][R] - ch[v1 - 1][R];
        long other = ch[v2][R];
        y += cur * other;
        v1--;
      } else {
        long cur = ch[v2][R] - ch[v2 - 1][R];
        long other = ch[v1][R];
        x += cur * other;
        v2--;
      }
    best = Math.abs(x - y);
    dfs(0, 0, R + C, R + C);
    str = readString();
    for (int i = 0; i < 2 * (R + C); i++) {
      cntA[i + 1] = cntA[i] + (str.charAt(i) == 'A' ? 1 : 0);
      cntB[i + 1] = cntB[i] + (str.charAt(i) == 'B' ? 1 : 0);
    }
    long ans = solve(0, 0, R + C, R + C);
    writer.println(ans);
  }
}


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

public class Test {
    int readInt() {
        int ans = 0;
        boolean neg = false;
        try {
            boolean start = false;
            for (int c = 0; (c = System.in.read()) != -1; ) {
                if (c == '-') {
                    start = true;
                    neg = true;
                    continue;
                } else if (c >= '0' && c <= '9') {
                    start = true;
                    ans = ans * 10 + c - '0';
                } else if (start) break;
            }
        } catch (IOException e) {
        }
        return neg ? -ans : ans;
    }

    int r, c;
    Scanner sca = new Scanner(System.in);
    long[][] C = new long[64][64];
    long best = Long.MAX_VALUE;

    void dfs(long x, long y, int v1, int v2) {
        long d = Math.abs(x - y);
        if (best <= 1 || d - C[v1][r]*C[v2][r] >= best) return;
        if (v1 == r - 1 && v2 == r - 1) {
            if (d < best) best = d;
            return;
        }
        if (v1 >= r) {
            long c1 = C[v1][r] - C[v1-1][r], s2 = C[v2][r];
            dfs(x, y + c1*s2, v1 - 1, v2);
        }
        if (v2 >= r) {
            long s1 = C[v1][r], c2 = C[v2][r] - C[v2-1][r];
            dfs(x + s1*c2, y, v1, v2 - 1);
        }
    }

    int[] cntA = new int[64], cntB = new int[64];
    Map<Long, Long> cache = new TreeMap<>();
    char[] cs;

    long solve(long x, long y, int v1, int v2) {
        long k = x*10000 + v1*100  + v2;
        Long v = cache.get(k);
        if (v != null) return v;
        v = 0l;
        long d = Math.abs(x - y);
        if (d - C[v1][r]*C[v2][r] > best) {
            cache.put(k, v);
            return v;
        }
        if (v1 < r || v2 < r) {
            int sum = v1 + v2;
            if (v1 >= cntA[sum] && v2 >= cntB[sum]) {
                v1 -= cntA[sum];
                v2 -= cntB[sum];
                v = C[v1+v2][v1];
                cache.put(k, v);
                return v;
            }
            cache.put(k, v);
            return v;
        }
        char c = cs[v1 + v2 - 1];
        if (c != 'B') {
            long c1 = C[v1][r] - C[v1 - 1][r], s2 = C[v2][r];
            v += solve(x, y + c1*s2, v1 - 1, v2);
        }
        if (c != 'A') {
            long s1 = C[v1][r], c2 = C[v2][r] - C[v2-1][r];
            v += solve( x + s1*c2, y, v1, v2 - 1);
        }
        cache.put(k, v);
        return v;
    }

    void start() {
        r = sca.nextInt(); c = sca.nextInt(); sca.nextLine();
        cs = sca.nextLine().toCharArray();
        for (int i = 0; i <= 2*(r + c); i++)
            for (int j = 0; j <= 2*(r + c); j++) {
                if (j == 0) C[i][j] = 1;
                else if (i == 0) C[i][j] = 0;
                else C[i][j] = C[i-1][j - 1] + C[i - 1][j];
            }
        int v1 = r + c, v2 = r + c;
        long x = 0, y = 0;
        while (v1 >= r && v2 >= 0) {
            if (x > y) {
                long c1 = C[v1][r] - C[v1 - 1][r], s2 = C[v2][r];
                y += c1*s2;
                v1--;
            } else {
                long s1 = C[v1][r], c2 = C[v2][r] - C[v2-1][r];
                x += s1*c2;
                v2--;
            }
        }
        best = Math.abs(x - y);
        dfs(0, 0, r + c, r + c);
        for (int i = 0; i < 2*(r+c); i++) {
            cntA[i + 1] = cntA[i] + (cs[i] == 'A' ? 1 : 0);
            cntB[i + 1] = cntB[i] + (cs[i] == 'B' ? 1 : 0);
        }
        long ans = solve(0, 0, r + c, r + c);
        System.out.println(ans);
    }

    public static void main(String[] args) {

        new Test().start();

    }
}


public class Main {

    public static void main(String[] args) throws IOException {
        Locale.setDefault(Locale.US);
//        BufferedReader entrada = new BufferedReader(new InputStreamReader(System.in));
//        BufferedReader entrada = new BufferedReader(new InputStreamReader(new FileInputStream("C:\\Users\\felipe.santos\\Documents\\entradas.txt")));
//        Scanner entrada = new Scanner(new FileInputStream("C:\\Users\\felipe.santos\\Documents\\entradas.txt"));///home/felipe/
        Scanner entrada = new Scanner(System.in);
        BufferedWriter saida = new BufferedWriter(new OutputStreamWriter(System.out));
//        BufferedWriter saida = new BufferedWriter(new OutputStreamWriter(new FileOutputStream("C:\\Users\\felipe.santos\\Documents\\saidas.txt")));;

        //left, straight, right, pedestrian
        boolean[][] lights = new boolean[4][4];
        for (int i = 0; i < 4; i++) {
            for (int j = 0; j < 4; j++) {
                lights[i][j] = entrada.nextInt() > 0;
            }
        }
        //por linha
        boolean res = false;
        for (int i = 0; i < 4 && !res; i++) {
            //sinal aberto + pedestre passando
            if (lights[i][3]) {
                for (int j = 0; j < 3 && !res; j++) {
                    if (lights[i][j]) {
                        res = true;
                    }
                }
            }
            //quais sinais estão abertos
            if (lights[i][0] && !res) {
                //esquerda
                int idx = ((i - 1) + 4) % 4;
                if (lights[idx][3])
                    res = true;
            }
            if (lights[i][1] && !res) {
                //reto
                int idx = (i + 2) % 4;
                if (lights[idx][3])
                    res = true;
            }
            if (lights[i][2] && !res) {
                //direita
                int idx = (i + 1) % 4;
                if (lights[idx][3])
                    res = true;
            }
        }

        if (res) {
            saida.write("YES");
        } else {
            saida.write("NO");
        }
        saida.write("\n");
        saida.flush();
    }
}


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

public class Main {
    public static final int SIZE = 4;
    private static PrintWriter out;

    public static void main(String[] args) {
        MyScanner sc = new MyScanner();
        out = new PrintWriter(new BufferedOutputStream(System.out));

        InputData[] inputDatas = new InputData[SIZE];

        for (int i = 0; i < inputDatas.length; i++) {
            inputDatas[i] = new InputData(sc.nextLine());
        }

        String answer = null;
        for (int i = 0; i < SIZE; i++) {
            if (!inputDatas[i].p)
                continue;
            for (int j = 0; j < SIZE; j++) {
                if (parseRoadNumber(j, inputDatas[(i + j) % SIZE])) {
                    answer = "YES";
                }
            }
        }

        if (answer == null) {
            answer = "NO";
        }

        out.println(answer);
        out.close();
    }

    private static boolean parseRoadNumber(int i, InputData data) {
        switch (i) {
            case 0:
            case 2:
                return data.s;
            case 1:
                return data.l;
            case 3:
                return data.r;
        }
    }

    static class InputData {
        final boolean l;
        final boolean s;
        final boolean r;
        final boolean p;

        InputData(String data) {
            final String[] split = data.split(" ");

            l = parseData(split[0]);
            s = parseData(split[1]);
            r = parseData(split[2]);
            p = parseData(split[3]);
        }

        private boolean parseData(String d) {
            return "1".equals(d);
        }
    }

    //-----------MyScanner class for faster input----------
    public static class MyScanner {
        BufferedReader br;
        StringTokenizer st;

        public MyScanner() {
            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;
        }

    }
}


import java.io.*;
import java.util.Scanner;
import java.util.StringTokenizer;

public class Main
{
    static class FastReader
    {
        final BufferedReader br;
        StringTokenizer st;

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

        FastReader(String inputFile){
            try {
                br = new BufferedReader(new InputStreamReader(new FileInputStream(inputFile)));
            } catch (FileNotFoundException e) {
                throw new RuntimeException(e);
            }
        }

        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 class FastWriter{
        PrintWriter printWriter;

        FastWriter(){
            printWriter = new PrintWriter(new BufferedOutputStream(System.out));
        }

        FastWriter(String outputFile){
            File file = new File(outputFile);
            if (!file.exists()){
                try {
                    if (!file.createNewFile())
                        throw new RuntimeException("Output file was not created!");
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            try {
                printWriter = new PrintWriter(new BufferedOutputStream(new FileOutputStream(file)));
            } catch (FileNotFoundException e) {
                throw new RuntimeException(e);
            }
        }

        void print(Object object){
            printWriter.print(object);
        }

        void print(Object ...objects){
            for (int i = 0; i < objects.length; i ++) {
                printWriter.print(objects[i]);
                if (i != objects.length - 1)
                    printWriter.write(' ');
            }
        }

        void flush(){
            printWriter.flush();
        }
    }

    public static void main(String[] args)
    {
        setup();
        xuly();
    }

    private static void setup() {
        Scanner scanner = new Scanner(System.in);
        int[] l = new int[4], r = new int[4], s = new int[4], p = new int[4];
        for (int i = 0; i < 4; i ++){
            l[i] = scanner.nextInt();
            s[i] = scanner.nextInt();
            r[i] = scanner.nextInt();
            p[i] = scanner.nextInt();
        }

        for (int i = 0; i < 4; i ++){
            int preDir = (i == 0? 3 : i - 1);
            int nexDir = (i == 3? 0 : i + 1);
            boolean accident = p[i] == 1 && (s[i] == 1 || r[preDir] == 1 || l[nexDir] == 1);
            if (accident){
                System.out.print("YES");
                return;
            }
        }
        System.out.print("NO");
    }

    private static void xuly() {
    }
}


import java.io.*;
import java.util.*;
import java.util.stream.IntStream;

public class Lesha {

  public static void main(String[] args) throws IOException {

    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    int size = Integer.parseInt(br.readLine());
    StringTokenizer st = new StringTokenizer(br.readLine());
    int[] numbers = new int[size];
    boolean allZeros = true;
    for(int i = 0; i < size; i++){
      numbers[i] = Integer.parseInt(st.nextToken());
      if(allZeros && numbers[i] != 0)
        allZeros = false;
    }

    if(allZeros){
      System.out.println("NO");
      return;
    }

    int sum = IntStream.of(numbers).sum();
    System.out.println("YES");
    if(sum != 0)
      System.out.println(1);
      System.out.println(1 + " " + size);
    else {
      System.out.println(2);
      for(int i = 0; i < size; i++){
        if(numbers[i] != 0){
          System.out.println(1 + " " + (i+1));
          System.out.println((i+2) +  " " +  size);
          return;
        }
      }
    }
  }
}


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

public class Main
{
    static BufferedReader br;
    static StringTokenizer st;
    static PrintWriter pr = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));

    public static void main(String[] args) throws IOException
	{
		br = new BufferedReader(new InputStreamReader(System.in));
        st = new StringTokenizer(br.readLine());

        int n=nxtInt();
        int[] a=new int[n];
        AL<Integer> idx=new AL<>();
        st = new StringTokenizer(br.readLine());
        for(int i=0; i<n; i++)
        {
            a[i]=nxtInt();
            if(a[i]==0) idx.add(i);
        }
        if(idx.size()==n) pr.println("NO");
        else
        {
            pr.println("YES\n1");
            pr.println("1 "+n);
        }

        pr.flush();
        pr.close();
    }

    static int nxtInt(){
        return Integer.parseInt(st.nextToken());
    }

    static long nxtLong(){
        return Long.parseLong(st.nextToken());
    }

    static double nxtDoub(){
        return Double.parseDouble(st.nextToken());
    }

    static String nxt(){
        return st.nextToken();
    }

    static String nxtLn() throws IOException{
        return br.readLine();
    }
}


public class Practice2 {

    public static void main(String[] args) throws IOException{
        BufferedReader read=new BufferedReader(new InputStreamReader(System.in));
        BufferedWriter wr=new BufferedWriter(new OutputStreamWriter(System.out));
        long n=Long.parseLong(read.readLine());
        String s=read.readLine();
        String s1[]=s.split(" ");
        int counter=0;
        int flagnonzero=0;
        int flagzero=0;
        long arr[]=new long[s1.length];
        for(int i=0;i<s1.length;i++){
            arr[i]=Long.parseLong(s1[i]);
            if(arr[i]!=0){
                flagnonzero=1;
            }
            else{
                flagzero=1;
            }
        }

        if(flagnonzero==0){
            System.out.println("NO");
        }

        else{
            System.out.println("YES");
            if(flagzero==0){
                counter=s1.length;
                for(int i=0;i<s1.length;i++){
                    wr.write((i+1)+" "+(i+1)+"\n");
                }
            }
            else{
                for(int i=0;i<s1.length;i++){
                    int temp=-1;
                    counter++;
                    if(arr[i]==0){
                    temp=i;
                    while(arr[i]==0){
                        i++;
                    }
                        wr.write((temp+1)+" "+(i+1)+"\n");
                    }
                    else{
                        wr.write((i+1)+" "+(i+1)+"\n");
                    }
                }

            }
        }
        System.out.println(counter);
        wr.flush();

    }

}


import java.util.ArrayList;

public class Main {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int f = -1;
        int s = -1;

        ArrayList<Integer> nums = new ArrayList<>();

        for (int i = 1; i <= n; i++) {
            int v = in.nextInt();
            if(v != 0) {
                nums.add(v);
            }
        }

        if(v.size() < 2) {
            System.out.print("NO");
        } else {
            System.out.println("YES");
            System.out.println(nums.size());

            int left = 1;
            for (int i = 0, size = nums.size() - 1; i < size; i++) {
                System.out.println(last + " " + nums.get(i));
                left = nums.get(i) + 1;
            }

            System.out.println(last + " " + n);
        }
    }

}


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

public class Cat {

    public static void main(String[] args) throws IOException {

        try(BufferedReader in = new BufferedReader(new InputStreamReader(System.in))) {

            String[] input = in.readLine().split(' ');

            int n = Integer.parseInt(input[0]);
            int m = Integer.parseInt(input[1]);

            if(m == 0) {
                System.out.println(1);
            } else if(n/2 >= m) {
                System.out.println(m);
            } else {
                System.out.println(n-m);

            }

        }

    }

}


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

public class Cat {

    public static void main(String[] args) throws IOException {

        try(BufferedReader in = new BufferedReader(new InputStreamReader(System.in))) {

            String input = in.readLine().split();

            int n = Integer.parseInt(input[0]);
            int m = Integer.parseInt(input[1]);

            if(m == 0) {
                System.out.println(1);
            } else if(n/2 >= m) {
                System.out.println(m);
            } else {
                System.out.println(n-m);

            }

        }

    }

}


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

public class EatingSoup {

	void findGroups(int available, int left) {
		if (available <= left) {
			System.out.println(0);
		} else if (left == 0) {
			System.out.println(1);
		} else {
			available--;
			left--;
			if ((left*2) == available) {
				System.out.println(left);
			} else {
				if ((left*2) < available) {
					System.out.println(left+1);
				} else {
					System.out.println(available-left);
				}
			}
		}
	}
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String str[] = br.readLine().split(" ");
		EatingSoup obj = new EatingSoup();
		obj.findGroups(Integer.parseInt(str[0]), Integer.parseInt(str[1]));

	}


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

public class X {

	public static void main(String[] args) {
		FastScanner in=new FastScanner();
		PrintWriter out=new PrintWriter(System.out);
	//	int t=in.nextInt();
	//	while(t-->0)
		solve(in,out);
		out.close();
	}

    static void solve(FastScanner in,PrintWriter out){
    int n=in.nextInt();
    int m=in.nextInt();
    int ans=Math.min(m,n-m);
    if(n!=m) ans=Math.max(ans,1)
    out.println(ans);
    }

	static class FastScanner {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");
		String next() {
			while (!st.hasMoreTokens())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());
		}
		int[] readArray(int n) {
			int[] a=new int[n];
			for (int i=0; i<n; i++) a[i]=nextInt();
			return a;
		}

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