import sun.reflect.generics.tree.Tree;

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

public class Template implements Runnable {

    BufferedReader in;
    PrintWriter out;
    StringTokenizer tok = new StringTokenizer("");

    void init() throws FileNotFoundException {
        try {
            in = new BufferedReader(new FileReader("input.txt"));
            out = new PrintWriter("output.txt");
        } catch (Exception e) {
            String filename = "king";
            if (filename.isEmpty()) {
                in = new BufferedReader(new InputStreamReader(System.in));
                out = new PrintWriter(System.out);
            } else {
                in = new BufferedReader(new FileReader(filename + ".in"));
                out = new PrintWriter(filename + ".out");
            }
        }
    }

    String readString() throws IOException {
        while (!tok.hasMoreTokens()) {
            try {
                tok = new StringTokenizer(in.readLine());
            } catch (Exception e) {
                return null;
            }
        }
        return tok.nextToken();
    }

    int readInt() throws IOException {
        return Integer.parseInt(readString());
    }

    int[] readIntArray(int size) throws IOException {
        int[] res = new int[size];
        for (int i = 0; i < size; i++) {
            res[i] = readInt();
        }
        return res;
    }

    long readLong() throws IOException {
        return Long.parseLong(readString());
    }

    double readDouble() throws IOException {
        return Double.parseDouble(readString());
    }

    <T> List<T>[] createGraphList(int size) {
        List<T>[] list = new List[size];
        for (int i = 0; i < size; i++) {
            list[i] = new ArrayList<>();
        }
        return list;
    }

    public static void main(String[] args) {
        new Thread(null, new Template(), "", 1l * 200 * 1024 * 1024).start();
    }

    long timeBegin, timeEnd;

    void time() {
        timeEnd = System.currentTimeMillis();
        System.err.println("Time = " + (timeEnd - timeBegin));
    }

    long memoryTotal, memoryFree;

    void memory() {
        memoryFree = Runtime.getRuntime().freeMemory();
        System.err.println("Memory = " + ((memoryTotal - memoryFree) >> 10)
                + " KB");
    }

    public void run() {
        try {
            timeBegin = System.currentTimeMillis();
            memoryTotal = Runtime.getRuntime().freeMemory();
            init();
            solve();
            out.close();
            if (System.getProperty("ONLINE_JUDGE") == null) {
                time();
                memory();
            }
        } catch (Exception e) {
            e.printStackTrace();
            System.exit(-1);
        }
    }

    char[][] ar = {
            "+------------------------+".toCharArray(),
            "|*.*.*.*.*.*.*.*.*.*.*.|D|)".toCharArray(),
            "|*.*.*.*.*.*.*.*.*.*.*.|.|".toCharArray(),
            "|*.......................|".toCharArray(),
            "|*.*.*.*.*.*.*.*.*.*.*.|.|)".toCharArray(),
            "+------------------------+".toCharArray()};

    void solve() throws IOException {
        int n = readInt();
        for (int j = 0; j < ar[0].length; j++){
            for (int i = 0; i < ar.length; i++) {
                if (ar[i][j] == '*') {
                    if (n > 0) {
                        ar[i][j] = 'O';
                        n--;
                    } else {
                        ar[i][j] = '#';
                    }
                }
            }
        }
        for (char[] x : ar) out.println(new String(x));
    }
}


public class Bayan {
    public static void main(String[]  args) {
        char [][] seating = new char [3][10];
        char [] lastrow =  new char[4];
        initializeMatrix(seating);
        initializeLastRow(lastrow);

       int k = Integer.parseInt(args[0]);

       k = setLastrow(k, lastrow);

      for (int j = 0 ; j< 10; j++) {
          for (int i= 0; i < 3; i++) {
              if (seating [i][j] != 0 && k != 0) {
                  seating[i][j] = '0';
                  k--;
              }
          }
      }

        //printMatrix(seating);
        printBus(seating, lastrow);

    }

    public static int setLastrow(int k, char[] lastrow) {

        int i = 0;
        while (k > 0 && i < 4) {
            lastrow[i] = '0';
            i++;
            k--;
        }
        return k;

    }
    public static void initializeMatrix(char[][] seating) {
        for (int i = 0; i< 3; i++) {
            for (int j=0; j<10 ;j++){
                seating[i][j] = '#';
            }
        }
    }

    public static void initializeLastRow(char[] lastrow) {
        for ( int i = 0 ; i< 4; i++) {
            lastrow[i] = '#';
        }
    }

    public static void printMatrix(char[][] seating) {
        for (int i = 0; i< 3; i++) {
            for (int j=0; j<10 ;j++){
                System.out.print(seating[i][j]);
            }
            System.out.println();
        }
    }

    public static void printBus(char[][] seating, char[] lastrow) {
        //print first line of bus
        System.out.println("+------------------------+");
        //print first row
        printrow(0, seating , lastrow);
        printrow(1, seating, lastrow);
        printEmptyRow(2, lastrow);
        printrow(2, seating, lastrow);
        //print last line of bus
        System.out.println("+------------------------+");

    }

    public static void printrow(int rownum, char[][] seating, char[] lastrow) {
        System.out.print("|");
        if ( rownum == 2) {
            System.out.print(lastrow[rownum+1] + ".");
        } else {
            System.out.print(lastrow[rownum] + ".");
        }
        for (int i= 0; i < 10; i++) {

            System.out.print(seating[rownum][i]+".");
        }

        if ( rownum == 0) {
            System.out.print("|D|)");

        } else if( rownum == 2) {
            System.out.print("|.|)");
        }
        else {
            System.out.print("|.|");
        }
        System.out.println();
    }

    public static void printEmptyRow(int rownum, char[] lastrow) {
        System.out.print("|");
        System.out.print(lastrow[rownum]+".");
        for (int i= 0; i < 21; i++) {

            System.out.print(".");
        }
        System.out.print(".|");
        System.out.println();
    }
}


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

public class Task {

    private void run() {
//        try {
//            Locale.setDefault(Locale.US);
//        } catch (Exception e) {
//        }
//
        try {
            sc = new FastScanner(new FileReader("input.txt"));
            out = new PrintWriter(new FileWriter("output.txt"));
        } catch (IOException e) {
            for (;;);
        }
        Solver s;
        s = new Solver();
        s.sc = sc;
        s.out = out;
        s.solve();
        out.flush();
        out.close();
        System.exit(0);
    }

    class Solver {

//    void ass(boolean OK) { if(!OK)Task.MLE(); }
//
        FastScanner sc;
        PrintWriter out;
////    static PrintStream err = System.err;
//

        char[][] arr = {
"+------------------------+" .toCharArray(),
"|#.#.#.#.#.#.#.#.#.#.#.|D|)".toCharArray(),
"|#.#.#.#.#.#.#.#.#.#.#.|.|" .toCharArray(),
"|#.......................|" .toCharArray(),
"|#.#.#.#.#.#.#.#.#.#.#.|.|)".toCharArray(),
"+------------------------+" .toCharArray()
};

        void set(){
            for( int j = 0; j < arr[0].length; ++j  ){
                for( int i = 0; i < arr.length; ++i ){
                    if( arr[i][j] == '#' ){
                        arr[i][j] = 'O';
                        return;
                    }
                }
            }
        }

        void solve() {
            int k = sc.nextInt();
            for (int i = 0; i < k; i++) {
                set();
            }
            for (char[] a : arr) {
                out.println( new String(a) );
            }
        }
    }

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

    static FastScanner sc;
    static PrintWriter out;
}

class FastScanner {

    BufferedReader br;
    StringTokenizer st;

    FastScanner(InputStreamReader reader) {
        br = new BufferedReader(reader);
        st = new StringTokenizer("");
    }

    String next() {
        while (!st.hasMoreElements()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (IOException ex) {
                for (;;);
            }
        }
        return st.nextToken();
    }

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

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

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


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.BufferedWriter;
import java.io.Writer;
import java.io.OutputStreamWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author prakharjain
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        OutputWriter out = new OutputWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB {
        public void solve(int testNumber, InputReader in, OutputWriter out) {

            long n = in.nextLong();

            long cn = n;

            long carry = 0;

            long ans = 0;
            while (cn > 0) {
                long num = cn % 10;

                if (cn / 10 == 0) {
                    ans += cn - carry;
                    break;
                } else {
                    long ntm = 10 + num;
                    ans += (ntm - carry);
                    carry = 1;
                }

                cn /= 10;
            }

            out.println(ans);
        }

    }

    static class OutputWriter {
        private final PrintWriter writer;

        public OutputWriter(OutputStream outputStream) {
            writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
        }

        public OutputWriter(Writer writer) {
            this.writer = new PrintWriter(writer);
        }

        public void close() {
            writer.close();
        }

        public void println(long i) {
            writer.println(i);
        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private InputReader.SpaceCharFilter filter;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public static boolean isWhitespace(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public int read() {
            if (numChars == -1) {
                throw new InputMismatchException();
            }
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0) {
                    return -1;
                }
            }
            return buf[curChar++];
        }

        public long nextLong() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            long res = 0;
            do {
                if (c < '0' || c > '9') {
                    throw new InputMismatchException();
                }
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public boolean isSpaceChar(int c) {
            if (filter != null) {
                return filter.isSpaceChar(c);
            }
            return isWhitespace(c);
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}


import java.util.*;
public class ph{
	//hi
	static long sum(long a){
		long s=0;
		while(a>0){
			long b=a%10;
			 s=s+b;
			a=a/10;
		}
		return s;
	}
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		long n=sc.nextLong();
		long i,j;
		long g[]=new long[(int)n];
		long a=n%10;
		long b=n-a;
		j=2;
		g[0]=sum(b)+sum(n-b);
		g[1]=sum(n);
		for(i=b-1;i>=0;i=i-10){
			g[(int)j]=sum(i)+sum(n-i);
			j++;
		}
		Arrays.sort(g);
		System.out.println(g[(int)n-1]);
	}
}


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

public class TaskB
{
    public static void main(String[] args)
    {
        new TaskB(System.in, System.out);
    }

    private static class Solver implements Runnable
    {
        long n;
        // BufferedReader in;
        InputReader in;
        PrintWriter out;

        void solve() throws IOException
        {
/*
            n = 75;

            int max = 0;

            for (int i = 0; i <= n; i++)
            {
                int a = i;
                int b = (int) (n - a);

                max = Math.max(max, s(a) + s(b));
            }

            out.println(max);*/

            n = in.nextLong();

            if (n < 9)
            {
                out.println(n);

                return;
            }

            long a = 9;
            long b = 0;
            long mul = 1;

            while (a <= n)
            {
                a *= 10;
                a += 9;
            }

            a /= 10;
            n -= a;

            if (n < 9)
            {
                out.println(s(a) + s(n));

                return;
            }

            b = 9;

            while (b <= n)
            {
                b *= 10;
                b += 9;
            }

            b /= 10;
            n -= b;

            b *= 10;
            b += n;

            out.println(s(a) + s(b));
        }

        int s(long x)
        {
            String str = "" + x;
            int sum = 0;

            for (char ch : str.toCharArray())
                sum += (ch - '0');

            return sum;
        }

        // uncomment below line to change to BufferedReader
        // public Solver(BufferedReader in, PrintWriter out)
        Solver(InputReader in, PrintWriter out)
        {
            this.in = in;
            this.out = out;
        }

        @Override
        public void run()
        {
            try
            {
                solve();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
        }

    }

    private static class InputReader
    {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;

        int read()
        {
            if (numChars == -1)
                throw new InputMismatchException();

            if (curChar >= numChars)
            {
                curChar = 0;
                try
                {
                    numChars = stream.read(buf);
                }
                catch (IOException e)
                {
                    throw new InputMismatchException();
                }
                if (numChars <= 0)
                    return -1;
            }

            return buf[curChar++];
        }

        int nextInt()
        {
            int c = read();

            while (isSpaceChar(c))
                c = read();

            int sgn = 1;

            if (c == '-')
            {
                sgn = -1;
                c = read();
            }

            int res = 0;

            do
            {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();

                res *= 10;
                res += c & 15;

                c = read();
            } while (!isSpaceChar(c));

            return res * sgn;
        }

        int[] nextIntArray(int arraySize)
        {
            int array[] = new int[arraySize];

            for (int i = 0; i < arraySize; i++)
                array[i] = nextInt();

            return array;
        }

        long nextLong()
        {
            int c = read();

            while (isSpaceChar(c))
                c = read();

            int sign = 1;

            if (c == '-')
            {
                sign = -1;

                c = read();
            }

            long result = 0;

            do
            {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();

                result *= 10;
                result += c & 15;

                c = read();
            } while (!isSpaceChar(c));

            return result * sign;
        }

        long[] nextLongArray(int arraySize)
        {
            long array[] = new long[arraySize];

            for (int i = 0; i < arraySize; i++)
                array[i] = nextLong();

            return array;
        }

        float nextFloat()
        {
            float result, div;
            byte c;

            result = 0;
            div = 1;
            c = (byte) read();

            while (c <= ' ')
                c = (byte) read();

            boolean isNegative = (c == '-');

            if (isNegative)
                c = (byte) read();

            do
            {
                result = result * 10 + c - '0';
            } while ((c = (byte) read()) >= '0' && c <= '9');

            if (c == '.')
                while ((c = (byte) read()) >= '0' && c <= '9')
                    result += (c - '0') / (div *= 10);

            if (isNegative)
                return -result;

            return result;
        }

        double nextDouble()
        {
            double ret = 0, div = 1;
            byte c = (byte) read();

            while (c <= ' ')
                c = (byte) read();

            boolean neg = (c == '-');

            if (neg)
                c = (byte) read();

            do
            {
                ret = ret * 10 + c - '0';
            } while ((c = (byte) read()) >= '0' && c <= '9');

            if (c == '.')
                while ((c = (byte) read()) >= '0' && c <= '9')
                    ret += (c - '0') / (div *= 10);

            if (neg)
                return -ret;

            return ret;
        }

        String next()
        {
            int c = read();

            while (isSpaceChar(c))
                c = read();

            StringBuilder res = new StringBuilder();

            do
            {
                res.appendCodePoint(c);

                c = read();
            } while (!isSpaceChar(c));

            return res.toString();
        }

        boolean isSpaceChar(int c)
        {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        String nextLine()
        {
            int c = read();

            StringBuilder result = new StringBuilder();

            do
            {
                result.appendCodePoint(c);

                c = read();
            } while (!isNewLine(c));

            return result.toString();
        }

        boolean isNewLine(int c)
        {
            return c == '\n';
        }

        void close()
        {
            try
            {
                stream.close();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
        }

        InputReader(InputStream stream)
        {
            this.stream = stream;
        }

    }

    private static class CMath
    {
        static long power(long number, long power)
        {
            if (number == 1 || number == 0 || power == 0)
                return 1;

            if (power == 1)
                return number;

            if (power % 2 == 0)
                return power(number * number, power / 2);
            else
                return power(number * number, power / 2) * number;
        }

        static long modPower(long number, long power, long mod)
        {
            if (number == 1 || number == 0 || power == 0)
                return 1;

            number = mod(number, mod);

            if (power == 1)
                return number;

            long square = mod(number * number, mod);

            if (power % 2 == 0)
                return modPower(square, power / 2, mod);
            else
                return mod(modPower(square, power / 2, mod) * number, mod);
        }

        static long moduloInverse(long number, long mod)
        {
            return modPower(number, mod - 2, mod);
        }

        static long mod(long number, long mod)
        {
            return number - (number / mod) * mod;
        }

        static int gcd(int a, int b)
        {
            if (b == 0)
                return a;
            else
                return gcd(b, a % b);
        }

        static long min(long... arr)
        {
            long min = arr[0];

            for (int i = 1; i < arr.length; i++)
                min = Math.min(min, arr[i]);

            return min;
        }

        static long max(long... arr)
        {
            long max = arr[0];

            for (int i = 1; i < arr.length; i++)
                max = Math.max(max, arr[i]);

            return max;
        }

        static int min(int... arr)
        {
            int min = arr[0];

            for (int i = 1; i < arr.length; i++)
                min = Math.min(min, arr[i]);

            return min;
        }

        static int max(int... arr)
        {
            int max = arr[0];

            for (int i = 1; i < arr.length; i++)
                max = Math.max(max, arr[i]);

            return max;
        }

    }

    private static class Utils
    {
        static boolean nextPermutation(int[] arr)
        {
            for (int a = arr.length - 2; a >= 0; --a)
            {
                if (arr[a] < arr[a + 1])
                {
                    for (int b = arr.length - 1; ; --b)
                    {
                        if (arr[b] > arr[a])
                        {
                            int t = arr[a];

                            arr[a] = arr[b];
                            arr[b] = t;

                            for (++a, b = arr.length - 1; a < b; ++a, --b)
                            {
                                t = arr[a];
                                arr[a] = arr[b];
                                arr[b] = t;
                            }

                            return true;
                        }
                    }
                }
            }

            return false;
        }

    }

    private TaskB(InputStream inputStream, OutputStream outputStream)
    {
        // uncomment below line to change to BufferedReader
        // BufferedReader in = new BufferedReader(new
        // InputStreamReader(inputStream));
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Thread thread = new Thread(null, new Solver(in, out), "Solver", 1 << 29);

        try
        {
            thread.start();
            thread.join();
        }
        catch (InterruptedException e)
        {
            e.printStackTrace();
        }

        in.close();
        out.flush();
        out.close();
    }

}


import java.util.Scanner;

/**
 * Copyright (c) 2017, Bongmi
 * All rights reserved
 * Author: shanhaosheng@bongmi.com
 */
public class Main {
  private static final Scanner IN = new Scanner(System.in);

  public static void main(String[] args) {
    while (IN.hasNext()) {
      String str = IN.next();
      str = str.replaceAll("0", " ").trim();
      if (str.equals(new StringBuilder(str).reverse().toString())) {
        System.out.println("YES");
      } else {
        System.out.println("NO");
      }
    }
  }
}


import java.util.Scanner;

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

	Scanner scan = new Scanner(System.in);
	String palin = scan.nextLine();
	if(palin.contains("0")){
		palin = palin.replace("0", "");
	}
	for(int i=0; i<palin.length(); i++){
		if(palin.charAt(i)!= (palin.charAt(palin.length()-1))){
			System.out.println("NO");
			return;
		} else {
			System.out.print("YES");
			return;

		}
	}
}
}


import java.util.Scanner;

public class ProblemA {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        String s = scan.next();
        int r = s.length() - 1;
        int end = r;

        if (s.charAt(0) != '0' && s.charAt(r) == '0') {
            while (s.charAt(r) == '0') {
                r--;
            }
            end = ((r + 1) & 1) == 1 ? r : r + 1;
        }

        boolean ok = true;
        for (int i = 0; i < end / 2; i++) {
            if (s.charAt(i) != s.charAt(r)) {
                ok = false;
                break;
            }
            r--;
        }

        if (ok) {
            System.out.println("YES");
        }
        else {
            System.out.println("NO");
        }

    }

}


import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Scanner;

public class A {

    public static void main(String[] args) {

        Scanner sc = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        HashSet<Integer> set = new HashSet<Integer>();
//_________________________________________________________________________________________________

        char[]a=sc.next().toCharArray();
        String h="";
        int x = a.length;boolean t=true;
        for (int i = 0; i < x;i++) {
                   if(a[i]!='0')
                         h+=a[i];

        }

        for(int i=0,j=h.length()-1;i<j;i++){
            if(h.charAt(i)!=h.charAt(j)){
                t=false;
                break;
            }
            else
                j--;
        }

        System.out.println(t? "YES":"NO");
//_________________________________________________________________________________________________
    }

}


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

import javax.print.attribute.HashAttributeSet;

import java.lang.*;
import java.math.*;
import java.text.DecimalFormat;
import java.lang.reflect.Array;
import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigDecimal;
import java.security.cert.TrustAnchor;
public class Codeforces{
	public static PrintWriter out = new PrintWriter (new BufferedOutputStream(System.out));
	static long MOD = (long)(1e9+7);
	//static int MOD = 998244353;
	static long MOD2 = MOD*MOD;
	static FastReader sc = new FastReader();
	static int pInf = Integer.MAX_VALUE;
	static int nInf = Integer.MIN_VALUE;
	public static void main(String[] args){
		int test = 1;
		//test = sc.nextInt();
		while(test-->0)solve();
		out.flush();
		out.close();
	}
	public static void solve() {
		precomp();
		int n = sc.nextInt();
		int x = sc.nextInt();
		int pos = sc.nextInt();
		int[] a = new int[n];
		Arrays.fill(a, -1);
		TreeSet<Integer> A = new TreeSet<>();
		for(int i = 1; i <= n; i++) {
			A.add(i);
		}
		int small = 0;
		int big = 0;
		int l = 0;
		int r = n;
		while(l<r) {
			int m = l+(r-l)/2;
			if(m==pos) {
				a[m] = x;
				A.remove(x);
				//out.println(a[m]+" "+m);
				break;
			}
			else if(m>pos) { //a[m]>x
				a[m] = A.higher(x);
				A.remove(a[m]);
				big++;
				//out.println(a[m]+" "+m);
				r = m;
			}
			else {          //a[m]<x
				a[m] = A.lower(x);
				A.remove(a[m]);
				small++;
				//out.println(a[m]+" "+m);
				l = m+1;
			}
		}
		long ans = 1L;
		ans = mul(ans, mul(nCk(x-1, small), facts[small]));
		ans = mul(ans, mul(nCk(n-x, big), facts[big]));
		ans = mul(ans, facts[A.size()]);
		out.println(ans);
	}
	static class Node{
		ArrayList<Node> connect = new ArrayList<>();
		int comp = -1;
		public int gsize() {
			return connect.size();
		}
	}
	static long nC2(long n) {
		return add((n*(n+1))/2, 0);
	}
	public static int maxRight(int x,int[] a) {
		int l = -1;      //a[l]<=x
		int r = a.length;//a[r]>x
		while(r-l>1) {
			int m = l+(r-l)/2;
			if(a[m]<=x) {
				l = m;
			}
			else {
				r = m;
			}
		}
		return l+1;
	}
	public static int minLeft(int x,int[] a) {
		int l = -1;      //a[l]<x
		int r = a.length;//a[r]>=x
		while(r-l>1) {
			int m = l+(r-l)/2;
			if(a[m]<x) {
				l = m;
			}
			else {
				r = m;
			}
		}
		return r+1;
	}
	public static int lowerBound(int key, int[] a) {
		int s = 0;
		int e = a.length-1;
		if(e==-1) {
			return 0;
		}
		int ans = -1;
		while(s<=e) {
			int m = s+(e-s)/2;
			if(a[m]>=key) {
				ans = m;
				e = m-1;
			}
			else {
				s = m+1;
			}
		}
		return ans==-1?s:ans;
	}
	public static int upperBound(int key, int[] a) {
		int s = 0;
		int e = a.length-1;
		if(e==-1) {
			return 0;
		}
		int ans = -1;
		while(s<=e) {
			int m = s+(e-s)/2;
			if(a[m]>key) {
				ans = m;
				e = m-1;
			}
			else {
				s = m+1;
			}
		}
		return ans==-1?s:ans;
	}
	public static long c2(long n) {
		if((n&1)==0) {
			return mul(n/2, n-1);
		}
		else {
			return mul(n, (n-1)/2);
		}
	}
	public static long mul(long a, long b){
	    return ((a%MOD)*(b%MOD))%MOD;
	}
	public static long add(long a, long b){
	    return ((a%MOD)+(b%MOD))%MOD;
	}
	public static long sub(long a, long b){
	    return ((a%MOD)-(b%MOD))%MOD;
	}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//Integer.lowestOneBit(i)   Equals k where k is the position of the first one in the binary
//Integer.highestOneBit(i)  Equals k where k is the position of the last one in the binary
//Integer.bitCount(i)       returns the number of one-bits
//Collections.sort(A,(p1,p2)->(int)(p2.x-p1.x)) To sort ArrayList in descending order wrt values of x.
//            Arrays.parallelSort(a,new Comparator<TPair>() {
//      		public int compare(TPair a,TPair b) {
//        			if(a.y==b.y) return a.x-b.x;
//        			return b.y-a.y;
//        		}
//        	});
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//PrimeFactors
    public static ArrayList<Long> primeFactors(long n) {
        ArrayList<Long> arr = new ArrayList<>();
        if (n % 2 == 0)
            arr.add((long) 2);
        while (n % 2 == 0)
            n /= 2;
        for (long i = 3; i <= Math.sqrt(n); i += 2) {
            int flag = 0;
            while (n % i == 0) {
                n /= i;
                flag = 1;
            }
            if (flag == 1)
                arr.add(i);
        }
        if (n > 2)
            arr.add(n);
        return arr;
    }
//Pair Class
    static class Pair implements Comparable<Pair>{
		int x;
		int y;
		int len;
		public Pair(int x, int y) {
			this.x = x;
			this.y = y;
			this.len = y-x+1;
		}
		@Override
		public int compareTo(Pair o) {
			if(this.x==o.x){
			    return (this.y-o.y);
			}
			return -1*(this.x-o.x);
		}
	}
	static class TPair implements Comparable<TPair>{
		int l;
		int r;
		long index;
		public TPair(int l, int r, long index) {
			this.l = l;
			this.r = r;
			this.index = index;
		}
		@Override
		public int compareTo(TPair o) {
			if(this.l==o.l){
			    return (this.r-o.r);
			}
			return -1*(this.l-o.l);
		}
	}
//nCr
	static long[] facts, factInvs;
	static long exp(long base, long e) {
		if (e==0) return 1;
		long half=exp(base, e/2);
		if (e%2==0) return mul(half, half);
		return mul(half, mul(half, base));
	}

	static long modInv(long x) {
		return exp(x, MOD-2);
	}

	static void precomp() {
		facts=new long[1_000_000];
		factInvs=new long[1_000_000];
		factInvs[0]=facts[0]=1;
		for (int i=1; i<facts.length; i++)
			facts[i]=mul(facts[i-1], i);
		factInvs[facts.length-1]=modInv(facts[facts.length-1]);
		for (int i=facts.length-2; i>=0; i--)
			factInvs[i]=mul(factInvs[i+1], i+1);
	}

	static long nCk(int n, int k) {
		return mul(facts[n], mul(factInvs[k], factInvs[n-k]));
	}
//Kadane's Algorithm
    static long maxSubArraySum(ArrayList<Long> a) {
    	if(a.size()==0) {
    		return 0;
    	}
    	long max_so_far = a.get(0);
    	long curr_max = a.get(0);
    	for (int i = 1; i < a.size(); i++) {
           curr_max = Math.max(a.get(i), curr_max+a.get(i));
           max_so_far = Math.max(max_so_far, curr_max);
    	}
    	return max_so_far;
    }
//Shuffle Sort
    static final Random random=new Random();
	static void ruffleSort(int[] a) {
		int n=a.length;//shuffle, then sort
		for (int i=0; i<n; i++) {
			int oi=random.nextInt(n), temp=a[oi];
			a[oi]=a[i]; a[i]=temp;
		}
		Arrays.sort(a);
	}
//Merge Sort
	static void merge(long arr[], int l, int m, int r)
    {
        // Find sizes of two subarrays to be merged
        int n1 = m - l + 1;
        int n2 = r - m;

        /* Create temp arrays */
        long L[] = new long [n1];
        long R[] = new long [n2];

        /*Copy data to temp arrays*/
        for (int i=0; i<n1; ++i)
            L[i] = arr[l + i];
        for (int j=0; j<n2; ++j)
            R[j] = arr[m + 1+ j];

        /* Merge the temp arrays */

        // Initial indexes of first and second subarrays
        int i = 0, j = 0;

        // Initial index of merged subarry array
        int k = l;
        while (i < n1 && j < n2)
        {
            if (L[i] <= R[j])
            {
                arr[k] = L[i];
                i++;
            }
            else
            {
                arr[k] = R[j];
                j++;
            }
            k++;
        }

        /* Copy remaining elements of L[] if any */
        while (i < n1)
        {
            arr[k] = L[i];
            i++;
            k++;
        }

        /* Copy remaining elements of R[] if any */
        while (j < n2)
        {
            arr[k] = R[j];
            j++;
            k++;
        }
    }

    // Main function that sorts arr[l..r] using
    // merge()
    static void sort(long arr[], int l, int r)
    {
        if (l < r)
        {
            // Find the middle point
            int m = (l+r)/2;

            // Sort first and second halves
            sort(arr, l, m);
            sort(arr , m+1, r);

            // Merge the sorted halves
            merge(arr, l, m, r);
        }
    }
//Brian Kernighans Algorithm
    static long countSetBits(long n){
        if(n==0) return 0;
        return 1+countSetBits(n&(n-1));
    }
//Factorial
    static long factorial(long n){
        if(n==1) return 1;
        if(n==2) return 2;
        if(n==3) return 6;
        return n*factorial(n-1);
    }
//Euclidean Algorithm
    static long gcd(long A,long B){
        if(B==0) return A;
        return gcd(B,A%B);
    }
//Modular Exponentiation
    static long fastExpo(long x,long n){
        if(n==0) return 1;
        if((n&1)==0) return fastExpo((x*x)%MOD,n/2)%MOD;
        return ((x%MOD)*fastExpo((x*x)%MOD,(n-1)/2))%MOD;
    }
//AKS Algorithm
    static boolean isPrime(long n){
        if(n<=1) return false;
        if(n<=3) return true;
        if(n%2==0 || n%3==0) return false;
        for(int i=5;i<=Math.sqrt(n);i+=6)
            if(n%i==0 || n%(i+2)==0) return false;
        return true;
    }
//Reverse an array
    static <T> void reverse(T arr[],int l,int r){
    	Collections.reverse(Arrays.asList(arr).subList(l, r));
    }
  //Print array
    static void print1d(long arr[]) {
    	out.println(Arrays.toString(arr));
    }
    static void print2d(int arr[][]) {
    	for(int a[]: arr) out.println(Arrays.toString(a));
    }
//Sieve of eratosthenes
    static int[] findPrimes(int n){
        boolean isPrime[]=new boolean[n+1];
        ArrayList<Integer> a=new ArrayList<>();
        int result[];
        Arrays.fill(isPrime,true);
        isPrime[0]=false;
        isPrime[1]=false;
        for(int i=2;i*i<=n;++i){
            if(isPrime[i]==true){
                for(int j=i*i;j<=n;j+=i) isPrime[j]=false;
            }
        }
        for(int i=0;i<=n;i++) if(isPrime[i]==true) a.add(i);
        result=new int[a.size()];
        for(int i=0;i<a.size();i++) result[i]=a.get(i);
        return result;

    }
//Indivisual factors of all nos till n
    static ArrayList<Integer>[] indiFactors(int n){
    	ArrayList<Integer>[] A = new ArrayList[n+1];
    	for(int i = 0; i <= n; i++) {
    		A[i] = new ArrayList<>();
    	}
    	int[] sieve = new int[n+1];
    	for(int i=2;i<=n;i++) {
       		if(sieve[i]==0) {
       			for(int j=i;j<=n;j+=i) if(sieve[j]==0) {
       				//sieve[j]=i;
       				A[j].add(i);
       			}
       		}
       	}
    	return A;
    }
//Segmented Sieve
    static boolean[] segmentedSieve(long l, long r){
    	boolean[] segSieve = new boolean[(int)(r-l+1)];
    	Arrays.fill(segSieve, true);
    	int[] prePrimes = findPrimes((int)Math.sqrt(r));
    	for(int p:prePrimes) {
    		long low = (l/p)*p;
    		if(low < l) {
    			low += p;
    		}
    		if(low == p) {
    			low += p;
    		}
    		for(long j = low; j<= r; j += p) {
    			segSieve[(int) (j-l)] = false;
    		}
    	}
    	if(l==1) {
    		segSieve[0] = false;
    	}
    	return segSieve;
    }
//Euler Totent function
    static long countCoprimes(long n){
        ArrayList<Long> prime_factors=new ArrayList<>();
        long x=n,flag=0;
        while(x%2==0){
            if(flag==0) prime_factors.add(2L);
            flag=1;
            x/=2;
        }
        for(long i=3;i*i<=x;i+=2){
            flag=0;
            while(x%i==0){
                if(flag==0) prime_factors.add(i);
                flag=1;
                x/=i;
            }
        }
        if(x>2) prime_factors.add(x);
        double ans=(double)n;
        for(Long p:prime_factors){
            ans*=(1.0-(Double)1.0/p);
        }
        return (long)ans;
    }
	static long modulo = (long)1e9+7;
	public static long modinv(long x){
	    return modpow(x, modulo-2);
	}
	public static long modpow(long a, long b){
	    if(b==0){
	        return 1;
	    }
	    long x = modpow(a, b/2);
	    x = (x*x)%modulo;
	    if(b%2==1){
	        return (x*a)%modulo;
	    }
	    return x;
	}
	public static class FastReader {
		BufferedReader br;
		StringTokenizer st;
		//it reads the data about the specified point and divide the data about it ,it is quite fast
		//than using direct

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

		String next() {
			while (st == null || !st.hasMoreTokens()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (Exception r) {
					r.printStackTrace();
				}
			}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());//converts string to integer
		}

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

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

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


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

public class C
{
	static long facts[],factInvs[],mod=(long)1e9+7;

	public static void main(String[] args)throws IOException
	{
		FastReader f=new FastReader();
		StringBuffer sb = new StringBuffer();
		precomp();

		int test=1;
		while(test-->0)
		{
			int n=f.nextInt();
			int x=f.nextInt();
			int pos=f.nextInt();

			int small=0;int big=0;
			int l=0;
			int r=n;
			while(l<r)
			{
				int mid=(l+r)/2;
				if(mid>pos)
					big++;
				if(mid<pos)
					small++;

				if(mid<=pos)
					l=mid+1;
				else
					r=mid;
			}
			long ans=(getNcR(x-1,small)
					    *getNcR(n-x,big)%mod
					    *facts[(n-small-big-1)]%mod
					    *facts[small]%mod
					    *facts[big]%mod);

			System.out.println(ans);
		}

    }

	static void precomp() {
		facts = new long[1000000];
		factInvs = new long[1000000];
		factInvs[0] = facts[0] = 1;

		for (int i = 1; i < facts.length; i++)
			facts[i] = mul(facts[i - 1], i);

		factInvs[facts.length - 1] = modInv(facts[facts.length - 1]);

		for (int i = facts.length - 2; i >= 0; i--)
			factInvs[i] = mul(factInvs[i + 1], i + 1);
	}

	static long getNcR(int n, int k) {
		return mul(facts[n], mul(factInvs[k], factInvs[n - k]));
	}

	static long mul(long a, long b) {
		return a * b % mod;
	}

	static long modInv(long x) {
		return exp(x, mod - 2);
	}

	static long exp(long base, long e) {
		if (e == 0)
			return 1;
		long half = exp(base, e / 2);
		if (e % 2 == 0)
			return mul(half, half);
		else
			return mul(half, mul(half, base));
	}

	static class FastReader
	{
	    BufferedReader br;
	    StringTokenizer st;

	    public FastReader() {
	    	br = new BufferedReader(new
	                 InputStreamReader(System.in));
	    }
	    String next() {
	        while (st == null || !st.hasMoreElements()) {
	            try{
	                st = new StringTokenizer(br.readLine());
	            }
	            catch (IOException  e) {
	                e.printStackTrace();
	            }
	        }
	        return st.nextToken();
	    }
	    int nextInt() {
	        return Integer.parseInt(next());
	    }
	    long nextLong() {
	        return Long.parseLong(next());
	    }
	    double nextDouble() {
	        return Double.parseDouble(next());
	    }
	    String nextLine() {
	        String str = "";
	        try{
	            str = br.readLine();
	        }
	        catch (IOException e) {
	            e.printStackTrace();
	        }
	        return str;
	    }
	}

}


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

import javax.print.attribute.HashAttributeSet;

import java.lang.*;
import java.math.*;
import java.text.DecimalFormat;
import java.lang.reflect.Array;
import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigDecimal;
import java.security.cert.TrustAnchor;
public class Codeforces{
	public static PrintWriter out = new PrintWriter (new BufferedOutputStream(System.out));
	static long MOD = (long)(1e9+7);
	//static int MOD = 998244353;
	static long MOD2 = MOD*MOD;
	static FastReader sc = new FastReader();
	static int pInf = Integer.MAX_VALUE;
	static int nInf = Integer.MIN_VALUE;
	public static void main(String[] args){
		int test = 1;
		//test = sc.nextInt();
		while(test-->0)solve();
		out.flush();
		out.close();
	}
	public static void solve() {
		precomp();
		int n = sc.nextInt();
		int x = sc.nextInt();
		int pos = sc.nextInt();
		int[] a = new int[n];
		Arrays.fill(a, -1);
		int small = 0;
		int big = 0;
		int l = 0;
		int r = n;
		while(l<r) {
			int m = l+(r-l)/2;
			if(m==pos) {
				//out.println(a[m]+" "+m);
				break;
			}
			else if(m>pos) { //a[m]>x
				big++;
				//out.println(a[m]+" "+m);
				r = m;
			}
			else {          //a[m]<x
				small++;
				//out.println(a[m]+" "+m);
				l = m+1;
			}
		}
		long ans = 1L;
		ans = mul(ans, mul(nCk(x-1, small), facts[small]));
		ans = mul(ans, mul(nCk(n-x, big), facts[big]));
		ans = mul(ans, facts[n-(small+big+1)]);
		out.println(ans);
	}
	static class Node{
		ArrayList<Node> connect = new ArrayList<>();
		int comp = -1;
		public int gsize() {
			return connect.size();
		}
	}
	static long nC2(long n) {
		return add((n*(n+1))/2, 0);
	}
	public static int maxRight(int x,int[] a) {
		int l = -1;      //a[l]<=x
		int r = a.length;//a[r]>x
		while(r-l>1) {
			int m = l+(r-l)/2;
			if(a[m]<=x) {
				l = m;
			}
			else {
				r = m;
			}
		}
		return l+1;
	}
	public static int minLeft(int x,int[] a) {
		int l = -1;      //a[l]<x
		int r = a.length;//a[r]>=x
		while(r-l>1) {
			int m = l+(r-l)/2;
			if(a[m]<x) {
				l = m;
			}
			else {
				r = m;
			}
		}
		return r+1;
	}
	public static int lowerBound(int key, int[] a) {
		int s = 0;
		int e = a.length-1;
		if(e==-1) {
			return 0;
		}
		int ans = -1;
		while(s<=e) {
			int m = s+(e-s)/2;
			if(a[m]>=key) {
				ans = m;
				e = m-1;
			}
			else {
				s = m+1;
			}
		}
		return ans==-1?s:ans;
	}
	public static int upperBound(int key, int[] a) {
		int s = 0;
		int e = a.length-1;
		if(e==-1) {
			return 0;
		}
		int ans = -1;
		while(s<=e) {
			int m = s+(e-s)/2;
			if(a[m]>key) {
				ans = m;
				e = m-1;
			}
			else {
				s = m+1;
			}
		}
		return ans==-1?s:ans;
	}
	public static long c2(long n) {
		if((n&1)==0) {
			return mul(n/2, n-1);
		}
		else {
			return mul(n, (n-1)/2);
		}
	}
	public static long mul(long a, long b){
	    return ((a%MOD)*(b%MOD))%MOD;
	}
	public static long add(long a, long b){
	    return ((a%MOD)+(b%MOD))%MOD;
	}
	public static long sub(long a, long b){
	    return ((a%MOD)-(b%MOD))%MOD;
	}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//Integer.lowestOneBit(i)   Equals k where k is the position of the first one in the binary
//Integer.highestOneBit(i)  Equals k where k is the position of the last one in the binary
//Integer.bitCount(i)       returns the number of one-bits
//Collections.sort(A,(p1,p2)->(int)(p2.x-p1.x)) To sort ArrayList in descending order wrt values of x.
//            Arrays.parallelSort(a,new Comparator<TPair>() {
//      		public int compare(TPair a,TPair b) {
//        			if(a.y==b.y) return a.x-b.x;
//        			return b.y-a.y;
//        		}
//        	});
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//PrimeFactors
    public static ArrayList<Long> primeFactors(long n) {
        ArrayList<Long> arr = new ArrayList<>();
        if (n % 2 == 0)
            arr.add((long) 2);
        while (n % 2 == 0)
            n /= 2;
        for (long i = 3; i <= Math.sqrt(n); i += 2) {
            int flag = 0;
            while (n % i == 0) {
                n /= i;
                flag = 1;
            }
            if (flag == 1)
                arr.add(i);
        }
        if (n > 2)
            arr.add(n);
        return arr;
    }
//Pair Class
    static class Pair implements Comparable<Pair>{
		int x;
		int y;
		int len;
		public Pair(int x, int y) {
			this.x = x;
			this.y = y;
			this.len = y-x+1;
		}
		@Override
		public int compareTo(Pair o) {
			if(this.x==o.x){
			    return (this.y-o.y);
			}
			return -1*(this.x-o.x);
		}
	}
	static class TPair implements Comparable<TPair>{
		int l;
		int r;
		long index;
		public TPair(int l, int r, long index) {
			this.l = l;
			this.r = r;
			this.index = index;
		}
		@Override
		public int compareTo(TPair o) {
			if(this.l==o.l){
			    return (this.r-o.r);
			}
			return -1*(this.l-o.l);
		}
	}
//nCr
	static long[] facts, factInvs;
	static long exp(long base, long e) {
		if (e==0) return 1;
		long half=exp(base, e/2);
		if (e%2==0) return mul(half, half);
		return mul(half, mul(half, base));
	}

	static long modInv(long x) {
		return exp(x, MOD-2);
	}

	static void precomp() {
		facts=new long[1_000_000];
		factInvs=new long[1_000_000];
		factInvs[0]=facts[0]=1;
		for (int i=1; i<facts.length; i++)
			facts[i]=mul(facts[i-1], i);
		factInvs[facts.length-1]=modInv(facts[facts.length-1]);
		for (int i=facts.length-2; i>=0; i--)
			factInvs[i]=mul(factInvs[i+1], i+1);
	}

	static long nCk(int n, int k) {
		return mul(facts[n], mul(factInvs[k], factInvs[n-k]));
	}
//Kadane's Algorithm
    static long maxSubArraySum(ArrayList<Long> a) {
    	if(a.size()==0) {
    		return 0;
    	}
    	long max_so_far = a.get(0);
    	long curr_max = a.get(0);
    	for (int i = 1; i < a.size(); i++) {
           curr_max = Math.max(a.get(i), curr_max+a.get(i));
           max_so_far = Math.max(max_so_far, curr_max);
    	}
    	return max_so_far;
    }
//Shuffle Sort
    static final Random random=new Random();
	static void ruffleSort(int[] a) {
		int n=a.length;//shuffle, then sort
		for (int i=0; i<n; i++) {
			int oi=random.nextInt(n), temp=a[oi];
			a[oi]=a[i]; a[i]=temp;
		}
		Arrays.sort(a);
	}
//Merge Sort
	static void merge(long arr[], int l, int m, int r)
    {
        // Find sizes of two subarrays to be merged
        int n1 = m - l + 1;
        int n2 = r - m;

        /* Create temp arrays */
        long L[] = new long [n1];
        long R[] = new long [n2];

        /*Copy data to temp arrays*/
        for (int i=0; i<n1; ++i)
            L[i] = arr[l + i];
        for (int j=0; j<n2; ++j)
            R[j] = arr[m + 1+ j];

        /* Merge the temp arrays */

        // Initial indexes of first and second subarrays
        int i = 0, j = 0;

        // Initial index of merged subarry array
        int k = l;
        while (i < n1 && j < n2)
        {
            if (L[i] <= R[j])
            {
                arr[k] = L[i];
                i++;
            }
            else
            {
                arr[k] = R[j];
                j++;
            }
            k++;
        }

        /* Copy remaining elements of L[] if any */
        while (i < n1)
        {
            arr[k] = L[i];
            i++;
            k++;
        }

        /* Copy remaining elements of R[] if any */
        while (j < n2)
        {
            arr[k] = R[j];
            j++;
            k++;
        }
    }

    // Main function that sorts arr[l..r] using
    // merge()
    static void sort(long arr[], int l, int r)
    {
        if (l < r)
        {
            // Find the middle point
            int m = (l+r)/2;

            // Sort first and second halves
            sort(arr, l, m);
            sort(arr , m+1, r);

            // Merge the sorted halves
            merge(arr, l, m, r);
        }
    }
//Brian Kernighans Algorithm
    static long countSetBits(long n){
        if(n==0) return 0;
        return 1+countSetBits(n&(n-1));
    }
//Factorial
    static long factorial(long n){
        if(n==1) return 1;
        if(n==2) return 2;
        if(n==3) return 6;
        return n*factorial(n-1);
    }
//Euclidean Algorithm
    static long gcd(long A,long B){
        if(B==0) return A;
        return gcd(B,A%B);
    }
//Modular Exponentiation
    static long fastExpo(long x,long n){
        if(n==0) return 1;
        if((n&1)==0) return fastExpo((x*x)%MOD,n/2)%MOD;
        return ((x%MOD)*fastExpo((x*x)%MOD,(n-1)/2))%MOD;
    }
//AKS Algorithm
    static boolean isPrime(long n){
        if(n<=1) return false;
        if(n<=3) return true;
        if(n%2==0 || n%3==0) return false;
        for(int i=5;i<=Math.sqrt(n);i+=6)
            if(n%i==0 || n%(i+2)==0) return false;
        return true;
    }
//Reverse an array
    static <T> void reverse(T arr[],int l,int r){
    	Collections.reverse(Arrays.asList(arr).subList(l, r));
    }
  //Print array
    static void print1d(long arr[]) {
    	out.println(Arrays.toString(arr));
    }
    static void print2d(int arr[][]) {
    	for(int a[]: arr) out.println(Arrays.toString(a));
    }
//Sieve of eratosthenes
    static int[] findPrimes(int n){
        boolean isPrime[]=new boolean[n+1];
        ArrayList<Integer> a=new ArrayList<>();
        int result[];
        Arrays.fill(isPrime,true);
        isPrime[0]=false;
        isPrime[1]=false;
        for(int i=2;i*i<=n;++i){
            if(isPrime[i]==true){
                for(int j=i*i;j<=n;j+=i) isPrime[j]=false;
            }
        }
        for(int i=0;i<=n;i++) if(isPrime[i]==true) a.add(i);
        result=new int[a.size()];
        for(int i=0;i<a.size();i++) result[i]=a.get(i);
        return result;

    }
//Indivisual factors of all nos till n
    static ArrayList<Integer>[] indiFactors(int n){
    	ArrayList<Integer>[] A = new ArrayList[n+1];
    	for(int i = 0; i <= n; i++) {
    		A[i] = new ArrayList<>();
    	}
    	int[] sieve = new int[n+1];
    	for(int i=2;i<=n;i++) {
       		if(sieve[i]==0) {
       			for(int j=i;j<=n;j+=i) if(sieve[j]==0) {
       				//sieve[j]=i;
       				A[j].add(i);
       			}
       		}
       	}
    	return A;
    }
//Segmented Sieve
    static boolean[] segmentedSieve(long l, long r){
    	boolean[] segSieve = new boolean[(int)(r-l+1)];
    	Arrays.fill(segSieve, true);
    	int[] prePrimes = findPrimes((int)Math.sqrt(r));
    	for(int p:prePrimes) {
    		long low = (l/p)*p;
    		if(low < l) {
    			low += p;
    		}
    		if(low == p) {
    			low += p;
    		}
    		for(long j = low; j<= r; j += p) {
    			segSieve[(int) (j-l)] = false;
    		}
    	}
    	if(l==1) {
    		segSieve[0] = false;
    	}
    	return segSieve;
    }
//Euler Totent function
    static long countCoprimes(long n){
        ArrayList<Long> prime_factors=new ArrayList<>();
        long x=n,flag=0;
        while(x%2==0){
            if(flag==0) prime_factors.add(2L);
            flag=1;
            x/=2;
        }
        for(long i=3;i*i<=x;i+=2){
            flag=0;
            while(x%i==0){
                if(flag==0) prime_factors.add(i);
                flag=1;
                x/=i;
            }
        }
        if(x>2) prime_factors.add(x);
        double ans=(double)n;
        for(Long p:prime_factors){
            ans*=(1.0-(Double)1.0/p);
        }
        return (long)ans;
    }
	static long modulo = (long)1e9+7;
	public static long modinv(long x){
	    return modpow(x, modulo-2);
	}
	public static long modpow(long a, long b){
	    if(b==0){
	        return 1;
	    }
	    long x = modpow(a, b/2);
	    x = (x*x)%modulo;
	    if(b%2==1){
	        return (x*a)%modulo;
	    }
	    return x;
	}
	public static class FastReader {
		BufferedReader br;
		StringTokenizer st;
		//it reads the data about the specified point and divide the data about it ,it is quite fast
		//than using direct

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

		String next() {
			while (st == null || !st.hasMoreTokens()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (Exception r) {
					r.printStackTrace();
				}
			}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());//converts string to integer
		}

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

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

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


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

public class TaskC {

    private static long MOD = 1_000_000_000+7;

    public static void main(String[] arg)  {
        final FastScanner in = new FastScanner(System.in);
        final PrintWriter out = new PrintWriter(System.out);
        final int n = in.nextInt();
        final int x = in.nextInt();
        final int pos = in.nextInt();
        out.println(solution(pos, n, x));
        out.close();
        in.close();
    }

    private static long solution(int pos,
                                   int len,
                                   int e){
        String path = bs(pos, len, e);
        //System.out.println(path);
        long permut = mod_fact(len-1-path.length());
        long traverse = traverse(e, 1, len, path.toCharArray(),0);
        return (permut*traverse)%MOD;
    }

    private static String bs(int pos, int len,
                           int element){
        int left = 0;
        int right = len;
        int deep = 1;
        StringBuilder path = new StringBuilder();
        while(left<right) {
            int middle = (left + right)/2;
            if(middle==pos){
                return path.toString();
            }
            deep++;

            if (middle < pos) {
                path.append('r');
                left = middle + 1;
            } else {
                path.append('l');
                right = middle;
            }
        }
        return path.toString();
    }

    private static long traverse(final int x,
                                 final int min,
                                 final int n,
                                 final char []s,
                                 final int p){
        if(p==s.length){
            return 1;
        }
        long result = 1;
        if(s[p]=='l'){
            for(int i=x+1;i<n;i++){
              result+=traverse(x, min, i, s, p+1)%MOD;
              result%=MOD;
            }
        }
        if(s[p]=='r'){
            for(int i=min;i<x;i++){
                result+=traverse(x, i, n, s, p+1)%MOD;
                result%=MOD;
            }
        }
        return result%MOD;
    }

    private  static int cnt(){
        int n = 9;
        int result = 0;
        for(int i=9;i>=1;i--){
                result+=(i-1);
        }
        return result;
    }

    private static long mod_fact(int n){
        long result =1;
        for(int i=2;i<=n;i++){
            result*=i;
            result%=MOD;
        }
        return result;
    }

    private static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        FastScanner(InputStream stream) {
            try {
                br = new BufferedReader(new InputStreamReader(stream));
            } catch (Exception e) {
                e.printStackTrace();
            }
        }

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

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

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

        void close() {
            try {
                br.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }

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

    }
}


import java.io.BufferedReader;
import java.util.Scanner;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Iterator;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;
import java.math.BigInteger;
public class A216
{
	static Scanner sc = new Scanner(System.in);
	static PrintWriter out = new PrintWriter(System.out);

	static void pn(Object o) {
		out.println(o);
		out.flush();

	}

	static void p(Object o) {
		out.print(o);
		out.flush();
	}

	static void pni(Object o) {
		out.println(o);
		System.out.flush();
	}

	static int I() throws IOException {
		return sc.nextInt();
	}

	static long L() throws IOException {
		return sc.nextLong();
	}

	static double D() throws IOException {
		return sc.nextDouble();
	}

	static String S() throws IOException {
		return sc.nextLine();
	}

	static char C() throws IOException {
		return sc.next().charAt(0);
	}
	static int[] Ai(int n) throws IOException {
		int[] arr = new int[n];

		for (int i = 0; i < n; i++)
			arr[i] = I();

		return arr;
	}

	static String[] As(int n) throws IOException {
		String s[] = new String[n];

		for (int i = 0; i < n; i++)
			s[i] = S();

		return s;
	}

	static long[] Al(int n) throws IOException {
		long[] arr = new long[n];

		for (int i = 0; i < n; i++)
			arr[i] = L();

		return arr;
	}
	public static void process() throws IOException
	{
	  int a=I();
	  int b=I();
	  int c=I();int sum=0;
	  while(2*(a+b+c)>6)
	  {
		  sum=sum+(2*(a+b+c)-6);
		  a=a-1;b=b-1;c=c-1;
	  }
	  if(a==b && b==c && c==a)
	  {
		  pn(sum+1);
	  }
	  else
	  if(a==b || b==c || c==a)
	  {
		  pn(sum-1);
	  }
	  else

		  pn(sum);

	}

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

		process();

	}

	}


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

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

/* Name of the class has to be "Main" only if the class is public. */
public class hexa
{
public static void main(String[] args) throws java.lang.Exception {
Scanner f = new Scanner(System.in);
		int x = f.nextInt();
		int y = f.nextInt();
		int z = f.nextInt();

		System.out.println(x*2+y*2+z*2);
}
}


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

public class Main
{
    static Scanner in = new Scanner( System.in );

    public static void main( String[] args )
    {
        int a = in.nextInt();
        int b = in.nextInt();
        int c = in.nextInt();
        int sum = 0;
        while ( a != 1 || b != 1 || c != 1 )
        {
            sum += ( a + b + c ) * 2 - 6;
            a--; b--; c--;
        }
        sum += a * b * c;
        System.out.println( sum );
    }
}


package Round_133;

import java.io.IOException;
import java.util.Scanner;

public class A {

    public static void main(String[] args) throws IOException {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int count = 0;
        while (a > 0 && b > 0 && c > 0) {
            count += a;
            count += b - 1;
            count += c - 1;
            count += a - 1;
            count += b - 1;
            count += c - 2;
            a--;
            b--;
            c--;
        }
        System.out.println(count);

    }
}


import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;

public class B {

    private static final Scanner scan = new Scanner(System.in);

    public static void main(String[] args) {
       int n = scan.nextInt();
       int k = scan.nextInt();
       int A = scan.nextInt();
       int B = scan.nextInt();
       int[] mem = new int[n+1];
       System.out.println(findResult(n,k,A,B,mem));
    }
    public static int findResult(int n, int k, int A, int B, int[] mem){
        if(n == 1){
            mem[n] = 0;
            return 0;
        }
        if(mem[n] > 0 ){
            return mem[n];
        }else{
            int subResult = findResult(n-1,k,A,B,mem);
            int divideResult = -1;
            if(n%k == 0){
                divideResult = findResult(n/k,k,A,B,mem);
            }
            if(divideResult < 0){
                mem[n] = subResult+A;
            }else{
                mem[n] = Math.min(subResult+A, divideResult+B);
            }
            return mem[n];
        }
    }

}


import java.util.Arrays;
import java.util.Scanner;

/**
 * 0da - 24.02.2018.
 */
public class B {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int k = scanner.nextInt();
        int A = scanner.nextInt();
        int B = scanner.nextInt();

        int[] array = new int[n + 1];

        Arrays.fill(array, Integer.MAX_VALUE);

        array[1] = 0;

        for (int i = 1; i < array.length; i++) {
            int price = array[i];
            int multiplication = i * k;
            if (multiplication <= n) {
                array[multiplication] = Math.min(price + B, array[multiplication]);
            }

            int inc = i+1;
            if (inc <= n) {
                array[inc] = Math.min(price + A, array[inc]);
            }
        }

        System.out.println(array[n]);
    }
}


import java.util.*;
import java.lang.*;
import java.io.*;
import java.math.BigInteger;
public class Solution
{
//    static class Com implements Comparator<Pair>{
//        public int compare(Pair A,Pair B)
//        {
//            return B.y-A.y;
//        }
//    }
    static class Pair{
        int parent;
        int rank;
        Pair(int parent,int rank)
        {
            this.rank=rank;
            this.parent=parent;
        }
    }
    static int find(Pair pr[],int i)
    {
        if(i==pr[i].parent)
            return i;
        else
        {
            pr[i].parent=find(pr,pr[i].parent);
            return pr[i].parent;
        }
    }
    static void join(Pair[] pr,int i,int j)
    {
        i=find(pr,i);
        j=find(pr,j);
        if(i==j)
            return;
        if(pr[i].rank>=pr[j].rank)
        {
            pr[j].parent=i;
            pr[i].rank+=pr[j].rank;
        }
        else
        {
            pr[i].parent = j;
            pr[j].rank+=pr[i].rank;
        }
    }
    static int dp[];
	public static void main (String[] args)
	{
          FastReader s1 = new FastReader();
          StringBuilder sb  = new StringBuilder();
          int n = s1.I();
          dp=new int[n+1];
          Arrays.fill(dp,Integer.MAX_VALUE);
          int k=s1.I();
          int A = s1.I();
          int B = s1.I();
            System.out.println(min(n,k,A,B));
        }
        static int min(int no,int k,int A,int B)
        {
            if(no==1)
                return 0;
            if(no%k!=0)
            {
                dp[no] = Math.min(A+min(no-1,k,A,B),dp[no]);
            }
            else
            {
                dp[no]=Math.min(min(no/k,k,A,B)+B, A+min(no-1,k,A,B));
            }
            return dp[no];
        }
        static int log2(int n)
        {
            double val = Math.log(n)/Math.log(2);
            return (int)val;
        }
        static int binary(int left,int right,int ar[],int no)
        {
             int mid=(left+right)/2;
             if(Math.abs(right-left)<=1)
             {
                 if(no>=ar[right])
                 {
                     return right+1;
                 }
                 else if(no<ar[left])
                 {
                     return left;
                 }
                 else
                 {
                      return left+1;
                 }
             }
             if(ar[mid]>no)
             {
                 right=mid-1;
                 return binary(left, right, ar, no);
             }
             else{
                 left=mid;
                 return binary(left, right, ar, no);
                         }
        }
	static class FastReader{
        BufferedReader br;
        StringTokenizer st;
        public FastReader()
        {
            br = new BufferedReader(new
                     InputStreamReader(System.in));
        }
        String next()
        {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException  e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

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

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

        String nextLine()
        {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }
    static int gcd(int a,int b)
		{
		    if(a%b==0)
		    return b;
		    return gcd(b,a%b);
		}
	static float power(float x, int y)
    {
        float temp;
        if( y == 0)
            return 1;
        temp = power(x, y/2);

        if (y%2 == 0)
            return temp*temp;
        else
        {
            if(y > 0)
                return x * temp * temp;
            else
                return (temp * temp) / x;
        }
    }
      static long pow(int x, int y)
    {
        int p = 1000000007;
        long res = 1;
        x = x % p;
        while (y > 0)
        {
            if((y & 1)==1)
                res = (res * x) % p;
            y = y >> 1;
            x = (x * x) % p;
        }
        return res;
    }
    static ArrayList<Integer> sieveOfEratosthenes(int n)
    {
        ArrayList<Integer> arr=new ArrayList<Integer>();
        boolean prime[] = new boolean[n+1];
        for(int i=2;i<n;i++)
            prime[i] = true;

        for(int p = 2; p*p <=n; p++)
        {
            if(prime[p] == true)
            {
                arr.add(p);
                for(int i = p*p; i <= n; i += p)
                    prime[i] = false;
            }
        }
        return arr;
    }
}


import java.util.Arrays;
import java.util.Scanner;

public class codeforces1 {
    static int k;
    static int a;
    static int b;
    static int dp[];
    static int getAns(int n) {
        if(n == 1) return 0;
        if(n <= 0) return (int)(2 *1E9 + 7);
        if(dp[n] != -1) {
            return dp[n];
        }
        int ans = (int)(2 * 1E9 + 7);
        if(n % k == 0 ) {
            ans = Math.min(getAns(n / k) + b, ans);
        }
        ans = Math.min(getAns(n - 1) + a, ans);
       // System.out.println(ans);
        return dp[n] = ans;
    }

    public static void main(String[] args) {
        // TODO Auto-generated method stub

        Scanner sc = new Scanner(System.in);
        int n;

        n = sc.nextInt();
        k = sc.nextInt();
        a = sc.nextInt();
        b = sc.nextInt();

        dp = new int[n + 1];
        Arrays.fill(dp, -1);
        System.out.println(getAns(n));
        // return getMinRemoval(arr, n, d);

    }

}


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

import static java.lang.Math.*;

public class TwoProblems implements Closeable {

    private InputReader in = new InputReader(System.in);
    private PrintWriter out = new PrintWriter(System.out);

    public void solve() {
        int x = in.ni(), t = in.ni(), a = in.ni(), b = in.ni(), da = in.ni(), db = in.ni();
        boolean[] can = new boolean[601];
        can[0] = true;
        for (int i = 0; i < t; i++) {
            int first = a - da * i;
            can[first] = true;
        }
        for (int j = 0; j <= t; j++) {
            int second = b - db * j;
            can[second] = true;
        }
        for (int i = 0; i <= x; i++) {
            if (can[i] && can[x - i]) {
                out.println("YES");
                return;
            }
        }
        out.println("NO");
    }

    @Override
    public void close() throws IOException {
        in.close();
        out.close();
    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

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

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

        public void close() throws IOException {
            reader.close();
        }
    }

    public static void main(String[] args) throws IOException {
        try (TwoProblems instance = new TwoProblems()) {
            instance.solve();
        }
    }
}


package Round_128_div_2;

import java.util.Scanner;

public class A {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int t = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();
		int da = sc.nextInt();
		int db = sc.nextInt();
		boolean f = false;
		for (int i = 0; i < t; i++) {
			for (int j = 0; j < t; j++) {
				if ((a - i * da) + (b - j * db) == x) {
					System.out.println("YES");
					return;
				}
			}
		}
			System.out.println("NO");
	}
}


package Round_128_div_2;

import java.util.Scanner;

public class A {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int t = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();
		int da = sc.nextInt();
		int db = sc.nextInt();
		boolean f = false;
		for (int i = 0; i < t; i++) {
			for (int j = 0; j < t; j++) {
				if ((a - i * da) + (b - j * db) == x) {
					f = true;
					break;
				}
			}
		}
		if (f) {
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}
	}
}


import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {
    Scanner in;
    PrintWriter out;

    class Pair {
        int len, v;

        Pair(int v, int l) {
            len = l;
            this.v = v;
        }
    }

    class List extends ArrayList<Pair> {
    }

    int inf = 1000 * 1000 * 1000;

    int[] levit(List[] a, int v1) {

        int d[] = new int[a.length];
        Arrays.fill(d, inf);
        d[v1] = 0;
        int[] state = new int[a.length];
        ArrayDeque<Integer> q = new ArrayDeque<Integer>();
        q.add(v1);
        int[] p = new int[a.length];
        Arrays.fill(p, -1);
        while (!q.isEmpty()) {
            int v = q.pollFirst();
            state[v] = 1;
            for (Pair i : a[v]) {
                int to = i.v;
                int len = i.len;
                if (d[to] > d[v] + len) {
                    d[to] = d[v] + len;
                    if (state[to] == 0) {
                        q.add(to);
                    } else if (state[to] == 1) {
                        q.addFirst(to);
                    }
                    p[to] = v;
                    state[to] = 1;
                }
            }
        }
        return d;
    }

    void setIn(String fI) {

        try {
            in = new Scanner(new FileInputStream(new File(fI)));
        } catch (FileNotFoundException e) {
            throw new Error(e);
        }
    }

    void setIn() {
        in = new Scanner(System.in);
    }

    void setOut(String fO) {
        try {
            out = new PrintWriter(new FileWriter(fO));
        } catch (IOException e) {
            throw new Error(e);
        }
    }

    void setOut() {
        out = new PrintWriter(System.out);
    }

    class Scanner {
        StringTokenizer st;
        BufferedReader in;
        String del;

        Scanner(InputStream is) {
            in = new BufferedReader(new InputStreamReader(is));
            st = null;
            del = " \t\n\r\f";
        }

        void setDelimiters(String del) {
            this.del = del;
        }

        String next() {
            if (st == null || !st.hasMoreTokens()) {
                st = new StringTokenizer(nextLine(), del);
            }
            return st.nextToken();
        }

        String nextLine() {
            try {
                st = null;
                return in.readLine();
            } catch (IOException e) {
                throw new Error(e);
            }
        }

        char nextChar() {
            try {
                char ch = (char) in.read();
                while (del.indexOf(ch) >= 0)
                    ch = (char) in.read();
                return ch;
            } catch (IOException e) {
                throw new Error(e);
            }
        }

        boolean hasNext() {
            try {
                return in.ready() || (st != null && st.hasMoreTokens());
            } catch (IOException e) {
                throw new Error(e);
            }
        }

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

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

        BigInteger nextBigInteger() {
            return new BigInteger(next());
        }

        BigDecimal nextBigDecimal() {
            return new BigDecimal(next());
        }

        int[] nextIntArray(int len) {
            int[] a = new int[len];
            for (int i = 0; i < len; i++) {
                a[i] = nextInt();
            }
            return a;
        }

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

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

    void run() {
        setIn();
        setOut();
        try {
            solve();
        } finally {
            out.close();
        }
    }

    void solve() {
        int x = in.nextInt();
        int t = in.nextInt();
        int a = in.nextInt();
        int b = in.nextInt();
        int da = in.nextInt();
        int db = in.nextInt();
        boolean[] s1 = new boolean[a + 1];
        boolean[] s2 = new boolean[b + 1];
        for (int i = 0; i < t; i++) {
            s1[a - da * i] = true;
            s2[b - db * i] = true;
        }
        for (int s = 0; s < s1.length; s++) {
            if ((x - s < s2.length && x - s >= 0 && s1[s] && s2[x - s])
                    || (x - s < s1.length && x - s >= 0 && s2[s] && s1[x - s])) {
                out.println("YES");
                return;
            }
        }
        out.println("NO");
    }
}


import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner input = new Scanner(System.in);
		int[] month = {31,28,31,30,31,30,31,31,30,31,30,31};
		int n = input.nextInt();
		String mon1 = "";
		String mon2 = "";
		String[] mon = new String [8];
		for(int i = 0;i < 12;i++){
			if(i == 1){
				mon1 += "29";
				mon2 += "28";
			}
			else{
				mon1 += String.valueOf(month[i]);
				mon2 += String.valueOf(month[i]);
			}
		}
		mon[0] = mon1 + mon1 + mon1;
		mon[1] = mon1 + mon1 + mon2;
		mon[2] = mon1 + mon2 + mon1;
		mon[3] = mon1 + mon2 + mon2;
		mon[4] = mon2 + mon1 + mon1;
		mon[5] = mon2 + mon1 + mon2;
		mon[6] = mon2 + mon2 + mon1;
		mon[7] = mon2 + mon2 + mon2;
		String target = "";
		for(int i = 0;i < n;i++)
			target += input.next();
		int sign = 0;
		for(int i = 0;i < 8;i++)
			if(mon[i].contains(target)){
				sign = 1;
				System.out.println("YES");
				break;
			}
		if(sign == 0)
			System.out.println("NO");
	}

}


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

public class Main {
	public static void main(String[] args) throws IOException {
       //Scanner sc = new Scanner(System.in);
       BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
       String pp = "31 28 31 30 31 30 31 31 30 31 30 31 31 28 31 30 31 30 31 31 30 31 30 31 31 29 31 30 31 30 31 31 30 31 30 31";
       String pp2 = "31 29 31 30 31 30 31 31 30 31 30 31 31 29 31 30 31 30 31 31 30 31 30 31 31 28 31 30 31 30 31 31 30 31 30 31";

       int t = Integer.parseInt(br.readLine());
       //StringBuilder str = new StringBuilder();

       String s = br.readLine();
      // System.out.println(s);
       Pattern p1 = Pattern.compile(s);
       Matcher m1 = p1.matcher(pp);

       boolean flag = false;

       while(m1.find()){
          System.out.println("Yes");
          flag = true;
          break;
       }

       if(!flag){
       	 Pattern p2 = Pattern.compile(s);
         Matcher m2 = p2.matcher(pp2);

         while(m2.find()){
            System.out.println("Yes");
            flag = true;
            break;
         }
       }

       if(!flag){
       	  System.out.println("No");
       }

	}
}


import java.util.*;
import java.io.*;
public class Test
{
public static void main(String[] args) throws IOException
{
    String str="31 29 31 30 31 30 31 31 30 31 30 31 31 28 31 30 31 30 31 31 30 31 30 31 31 29 31 30 31 30 31 31 30 31 30 31 31 29 31 30 31 30 31 31 30 31 30 31";
    Scanner sc=new Scanner(System.in);
    int n=sc.nextInt();
    sc.nextLine();
    String s=sc.nextLine();
    if(str.indexOf(s)>=0){
        System.out.println("YES");
    }
    else{
        System.out.println("NO");
    }

}
}


import java.util.*;
import java.util.Collections;
public class JavaApplication7 {
      public static void main(String[] args) {
          Scanner input = new Scanner(System.in);
          int[] arr = new int[13];
          arr[1]=31;
          arr[2]=28;
          arr[3]=31;
          arr[4]=30;
          arr[5]=31;
          arr[6]=30;
          arr[7]=31;
          arr[8]=31;
          arr[9]=30;
          arr[10]=31;
          arr[11]=30;
          arr[12]=31;
          int n =input.nextInt();
          String answer = "Yes";
          String entry ="";

          for(int i=0;i<n;i++)
          {
                 int x =input.nextInt();
                 if(x==29) arr[2]=29;
                 entry += x+" ";
          }
          String months = arr[1]+" "+arr[2]+" "+arr[3]+" "+arr[4]+" "+arr[5]+" "+arr[6]+" "+arr[7]+" "+arr[8]+" "+arr[9]+" "+arr[10]+" "+arr[11]+" "+arr[12]+" ";
          boolean found = months.contains(entry);

          if(found)System.out.println("Yes");
          else{
                for(int i=1;i<=n;i++)
                    months+=months;

                found = months.contains(entry);

          if(found)System.out.println("Yes");
          else System.out.println("No");

          }
      }}


import java.io.BufferedOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;

public class C519 {

    public static void main(String[] args) throws Exception {
        PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out));
        Reader sc = new Reader();
        int n = sc.i(), m = sc.i();
        int teams = countTeams(n, m);
        out.println(teams);
        out.flush();
    }

    private static int countTeams(int xp, int nb) {
        int[][] dp = new int[xp][nb];
        for (int i = 0; i < xp; i++) Arrays.fill(dp[i], -1);
        return countTeamsUtil(xp, nb, 0, dp);
    }

    private static int countTeamsUtil(int xp, int nb, int count, int[][] dp) {
        if (xp < 1 || nb < 1 || (nb==1 && xp==1)) return count;
        if (dp[xp - 1][nb - 1] != -1) return dp[xp - 1][nb - 1];
        dp[xp - 1][nb - 1] = Math.max(countTeamsUtil(xp - 2, nb - 1, count + 1, dp),
                countTeamsUtil(xp - 1, nb - 2, count + 1, dp));
        return dp[xp - 1][nb - 1];
    }

    static class Reader {
        private InputStream mIs;
        private byte[] buf = new byte[1024];
        private int curChar, numChars;

        public Reader() {
            this(System.in);
        }

        public Reader(InputStream is) {
            mIs = is;
        }

        public int read() {
            if (numChars == -1) throw new InputMismatchException();
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = mIs.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0) return -1;
            }
            return buf[curChar++];
        }

        public String nextLine() {
            int c = read();
            while (isSpaceChar(c)) c = read();
            StringBuilder res = new StringBuilder();
            do {
                res.appendCodePoint(c);
                c = read();
            } while (!isEndOfLine(c));
            return res.toString();
        }

        public String s() {
            int c = read();
            while (isSpaceChar(c)) c = read();
            StringBuilder res = new StringBuilder();
            do {
                res.appendCodePoint(c);
                c = read();
            } while (!isSpaceChar(c));
            return res.toString();
        }

        public long l() {
            int c = read();
            while (isSpaceChar(c)) c = read();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            long res = 0;
            do {
                if (c < '0' || c > '9') throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public int i() {
            int c = read();
            while (isSpaceChar(c)) c = read();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9') throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public double d() throws IOException {
            return Double.parseDouble(s());
        }

        public boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public boolean isEndOfLine(int c) {
            return c == '\n' || c == '\r' || c == -1;
        }

        public int[] arr(int n) {
            int[] ret = new int[n];
            for (int i = 0; i < n; i++) {
                ret[i] = i();
            }
            return ret;
        }
    }
}


import java.io.*;
import java.util.*;
//public final class code
class code
{
	static int dp[][];
	static int ans(int n,int m)
	{

		if(n==0 && m==0)
			return 0;
		if(n<0 || m<0)
			return -1;
		if(dp[n][m]!=0)
			return dp[n][m];
		dp[n][m]=Math.max(1+ans(n-1,m-2),1+ans(n-2,m-1));
		return dp[n][m];
	}
	static void solve()throws IOException
	{
		int n=nextInt();
		int m=nextInt();
		dp=new int[n+1][m+1];
		out.println(ans(n,m));
	}

	///////////////////////////////////////////////////////////
	static final long mod=(long)(1e9+7);
	static final int inf=(int)(1e9);
	static class Pair implements Comparable<Pair>
	{
		int first,second;
		Pair(int a,int b)
		{
			first=a;
			second=b;
		}
		public int compareTo(Pair p)
		{
			return this.second-p.second;
		}
	}
	static BufferedReader br;
	static StringTokenizer st;
	static PrintWriter out;
	static String nextToken()throws IOException
	{
		while(st==null || !st.hasMoreTokens())
			st=new StringTokenizer(br.readLine());
		return st.nextToken();
	}
	static String nextLine()throws IOException
	{
		return br.readLine();
	}
	static int nextInt()throws IOException
	{
		return Integer.parseInt(nextToken());
	}
	static long nextLong()throws IOException
	{
		return Long.parseLong(nextToken());
	}
	static double nextDouble()throws IOException
	{
		return Double.parseDouble(nextToken());
	}
	public static void main(String args[])throws IOException
	{
		br=new BufferedReader(new InputStreamReader(System.in));
		out=new PrintWriter(new BufferedOutputStream(System.out));
		solve();
		out.close();
	}
}


import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int m = in.nextInt();
        int [][] dp = new int [n+1][m+1];
        for (int i = 2; i <= m; i++) {
            dp[1][i] = 1;
        }
        for (int i = 2; i <= n; i++) {
            dp[i][1] = 1;
        }

        for (int i = 2; i <= n; i++) {
            for (int j = 2; j <= m; j++) {
                int x = Math.max(dp[i-1][j-2], dp[i-2][j-1]);
                dp[i][j] = x + 1;
            }
        }

        System.out.println(dp[n][m]);

    }
}


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

public class test
{

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

        String s[] = br.readLine().split(" ");
        int n = Integer.parseInt(s[0]);
        int m = Integer.parseInt(s[1]);

        int dp[][] = new int[n+1][m+1];
        dp[1][1]=0;
        for(int i=2;i<=m;i++)
        {
            dp[1][i]=1;
        }
        for(int i=2;i<=n;i++)
        {
            dp[i][1]=1;
        }

        for(int i=2;i<=n;i++)
        {
            for(int j=2;j<=m;j++)
            {
                int max = Math.max(i,j);
                if(max==i)
                {
                    dp[i][j] = dp[i-2][j-1]+1;
                }
                else if(max==j)
                {
                    dp[i][j] = dp[i-1][j-2]+1;
                }
            }
        }

        System.out.println(dp[n][m]);

    }

}


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

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author captainTurtle
 */
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);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int k = in.nextInt();
            int n = in.nextInt();
            int g = 0, w = 0, s = 0;

            if ((k / 2) > n) {
                for (int i = 0; i < 3; i++) {
                    if ((k / 2) % 3 == 0) {
                        g = k / 6;
                        w = k / 3;
                        s = k - (g + w);
                        System.out.print(g);
                        System.out.print(" ");
                        System.out.print(w);
                        System.out.print(" ");
                        System.out.print(s);
                    } else {
                        continue;
                    }
                    k--;
                }
            } else {
                g = 0;
                w = 0;
                System.out.print(g);
                System.out.print(" ");
                System.out.print(w);
                System.out.print(" ");
                System.out.print(k - (g + w));
            }
        }

    }
}


import java.util.Scanner;
import java.io.IOException;

/**
 * Created by Shoumik on 01-Aug-17.
 */

public class Dc {
    public static void main(String [] args) throws IOException
    {
        Scanner sc = new Scanner(System.in);
        long i, n=sc.nextLong();
        int  k=sc.nextInt();

        for(i=0; i*i*i*k*k*k<n; i++)
        {
            if(i*i*i*k*k*k==n)
            {
                System.out.println(i+" "+k*i+" "+" "+ k*k*i);
                break;
            }
        }

        for(i=n/2/(k+1); i>=0; i--)
        {

            if (i*(k+1)<=n/2)
            {
                    System.out.println(i+ " "+ k*i +" "+ (n-i*(k+1)));
                    break;
            }
        }

    }

}


import java.util.*;
public class BalanceScale {
	public static void main(String[] args){
	Scanner in = new Scanner(System.in);
	while(in.hasNext()){
		int n = in.nextInt();
		int k = in.nextInt();
		int a,b,c;
		a=n/2/(k+1);
		b=a*k;
		c=n-a-b;
		System.out.println(a+" "+b+" "+c);
	}
}
}


import java.util.Scanner;
import java.io.IOException;

/**
 * Created by Shoumik on 01-Aug-17.
 */

public class Dc {
    public static void main(String [] args) throws IOException
    {
        Scanner sc = new Scanner(System.in);

        int i,n=sc.nextInt(), k=sc.nextInt(), x,y,z;

        for(i=0; i*i*i*k*k*k<n; i++)
        {
            if(i*i*i*k*k*k==n)
            {
                System.out.println(i+" "+k*i+" "+" "+ k*k*i);
                break;
            }
        }

        for(i=n/2; i>=0; i--)
        {
            if (i*(k+1)<=n/2)
            {
                    System.out.println(i+ " "+ k*i +" "+ (n-i*(k+1)));
                    break;
            }
        }

    }

}


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

/**
 * @author mohanad
 *
 */
public class P8_Div2_118D {

	/**
	 * @param args
	 * @throws IOException
	 */
	public static void main(String[] args) throws IOException {
		BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));

		String nk[]=bf.readLine().split(" ");
		n1=Integer.parseInt(nk[0]);
		n2=Integer.parseInt(nk[1]);
		k1=Integer.parseInt(nk[2]);
		k2=Integer.parseInt(nk[3]);
		dp=new int [101][101][101][101];
		for (int a[][][]:dp)
			for (int s[][]:a)
				for (int ss[]:s)
						Arrays.fill(ss, -1);
//		System.out.println("start");
		System.out.println(solv(0, 0, 0, 0 ));
	}

	static int n1,n2,k1,k2 , dp[][][][];
	static int solv (int f , int h , int fsum , int hsum ){
		if ((fsum+hsum)==(n1+n2)){
//			System.out.println(s);
			return 1 ;

		}
		if (dp[f][h][fsum][hsum]!=-1){
//			System.out.println("dp");
			return dp[f][h][fsum][hsum];
		}
//
		int a=0;
		if (f<k1 && fsum<n1){
			a=solv(f+1, 0, fsum+1 , hsum)%100000000 ;
		}
		if (h<k2 && hsum<n2)
			a+=solv(0, h+1, fsum , hsum+1)%100000000;
//		String v=(f+" "+h+" "+(fsum+" "+hsum) + " "+(f_h?0:1) + " ="+a);
//		System.out.println(fsum+" f= "+f +" "+hsum +" h ="+h+ " "+f_h+" "+a);
//
		return dp[f][h][fsum][hsum]=a;
	}
}


import java.util.Arrays;
import java.util.Scanner;

public class CaesarsLegions {
	static int[][][][][] dp;

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n1 = sc.nextInt();
		int n2 = sc.nextInt();
		int k1 = sc.nextInt();
		int k2 = sc.nextInt();

		dp = new int[n1 + n2 + 1][n1 + 1][n2 + 1][n1 + 1][n2 + 1];

		for (int i = 0; i < dp.length; i++)
			for (int j = 0; j < n1 + 1; j++)
				for (int k = 0; k < n2 + 1; k++)
					for (int jj = 0; jj < n1 + 1; jj++)
						Arrays.fill(dp[i][j][k][jj], -1);

		System.out
				.println(getCount(n1, n2, k1, k2, 0, 0, 0, 0, 0, 0) % 100000000);
	}

	private static int getCount(int n1, int n2, int k1, int k2, int c1, int c2,
			int counter, int cc1, int cc2, int last) {
		if (c1 > k1 || c2 > k2 || cc1 > n1 || cc2 > n2)
			return 0;

		if (counter == n1 + n2)
			return 1;

		if (dp[counter][c1][c2][cc1][cc2] != -1)
			return dp[counter][c1][c2][cc1][cc2];

		return dp[counter][c1][c2][cc1][cc2] = getCount(n1, n2, k1, k2, c1 + 1,
				0, counter + 1, cc1 + 1, cc2, 1)
				% 100000000
				+ getCount(n1, n2, k1, k2, 0, c2 + 1, counter + 1, cc1,
						cc2 + 1, 2) % 100000000;
	}
}


import java.util.Arrays;
import java.util.Scanner;

public class CaesarsLegions {
	static int[][][][] dp;

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n1 = sc.nextInt();
		int n2 = sc.nextInt();
		int k1 = sc.nextInt();
		int k2 = sc.nextInt();

		dp = new int[n1 + 1][n2 + 1][n1 + 1][n2 + 1];

		for (int j = 0; j < n1 + 1; j++)
			for (int k = 0; k < n2 + 1; k++)
				for (int jj = 0; jj < n1 + 1; jj++)
					Arrays.fill(dp[j][k][jj], -1);

		System.out
				.println(getCount(n1, n2, k1, k2, 0, 0, 0, 0, 0, 0) % 100000000);
	}

	private static int getCount(int n1, int n2, int k1, int k2, int c1, int c2,
			int counter, int cc1, int cc2, int last) {
		if (c1 > k1 || c2 > k2 || cc1 > n1 || cc2 > n2)
			return 0;

		if (counter == n1 + n2)
			return 1;

		if (dp[c1][c2][cc1][cc2] != -1)
			return dp[c1][c2][cc1][cc2];

		return dp[c1][c2][cc1][cc2] = getCount(n1, n2, k1, k2, c1 + 1, 0,
				counter + 1, cc1 + 1, cc2, 1)
				% 100000000
				+ getCount(n1, n2, k1, k2, 0, c2 + 1, counter + 1, cc1,
						cc2 + 1, 2) % 100000000;
	}
}


import java.util.Arrays;
import java.util.Scanner;

public class four {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n1 = sc.nextInt();
        int n2 = sc.nextInt();
        int k1 = sc.nextInt();
        int k2 = sc.nextInt();
        int[][][][][] dp = new int[n1 + n2][n1 + 1][n2 + 1][2][Math.max(n1, n2) + 1];
        for (int i = 0; i < dp.length; i++)
            for (int j = 0; j < dp[0].length; j++)
                for (int k = 0; k < dp[0][0].length; k++)
                    for (int l = 0; l < dp[0][0][0].length; l++)
                        Arrays.fill(dp[i][j][k][l], -1);

        long ans = go(1, n1 - 1, n2, k1, k2, true, 1, dp) % 100000000;
        ans += go(1, n1, n2 - 1, k1, k2, false, 1, dp) % 100000000;
        System.out.println(ans % 100000000);
    }

    private static int go(int place, int n1, int n2, int k1, int k2,
            boolean type, int count, int[][][][][] dp) {
        if (n1 < 0 || n2 < 0)
            return 0;
        if (type && count > k1 || !type && count > k2)
            return 0;
        if (place == dp.length)
            return 1;
        if (dp[place][n1][n2][(type) ? 0 : 1][count] != -1)
            return dp[place][n1][n2][(type) ? 0 : 1][count];
        else {
            int sum = 0;

            sum += go(place + 1, n1 - 1, n2, k1, k2, true, (type) ? count + 1
                    : 1, dp) % 100000000;
            sum += go(place + 1, n1, n2 - 1, k1, k2, false, (!type) ? count + 1
                    : 1, dp) % 100000000;
            return dp[place][n1][n2][(type) ? 0 : 1][count] = sum % 100000000;
        }
    }
}


import java.util.HashSet;
import java.util.Scanner;

public class Main {
    static HashSet<Integer> memoizacija;

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

        int N = sc.nextInt();

        int res1 = 0;

        for(int i = 0; i<810; i++){
            int res2 = 0;
            for(int j = 0; j<8100; j++){
                int res = N - res1 - res2;
                if(res > 0 && res%1234 == 0){
                    System.out.println("YES");
                    System.exit(0);
                }
                res2 += 123456;
            }
            res1 += 1234567;
        }

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