import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;

public final class CuttingBanner {

class NumberUtil {

    private static Map<Integer, String> uniqueWords = new HashMap<Integer, String>();

    static {
        uniqueWords.put(0, "");
        uniqueWords.put(1, "one");
        uniqueWords.put(2, "two");
        uniqueWords.put(3, "three");
        uniqueWords.put(4, "four");
        uniqueWords.put(5, "five");
        uniqueWords.put(6, "six");
        uniqueWords.put(7, "seven");
        uniqueWords.put(8, "eight");
        uniqueWords.put(9, "nine");
        uniqueWords.put(10, "ten");
        uniqueWords.put(11, "eleven");
        uniqueWords.put(12, "twelve");
        uniqueWords.put(13, "thirteen");
        uniqueWords.put(14, "fourteen");
        uniqueWords.put(15, "fifteen");
        uniqueWords.put(16, "sixteen");
        uniqueWords.put(17, "seventeen");
        uniqueWords.put(18, "eighteen");
        uniqueWords.put(19, "nineteen");
        uniqueWords.put(20, "twenty");
        uniqueWords.put(30, "thirty");
        uniqueWords.put(40, "forty");
        uniqueWords.put(50, "fifty");
        uniqueWords.put(60, "sixty");
        uniqueWords.put(70, "seventy");
        uniqueWords.put(80, "eighty");
        uniqueWords.put(90, "ninety");
        uniqueWords.put(100, "hundred");
        uniqueWords.put(1000, "one thousand");
    }

    static public String getLetterRepresentation(int num) {
        StringBuilder numInWords = new StringBuilder();
        if (num <= 20) {
            numInWords.append(uniqueWords.get(num));
        } else if (num < 100) {
            numInWords.append(uniqueWords.get((num / 10) * 10)).append(" ").append(uniqueWords.get(num % 10));
        } else if (num == 1000) {
            numInWords.append(uniqueWords.get(num));
        } else if (num % 100 == 0) {
            numInWords.append(uniqueWords.get(num / 100)).append(" ").append(uniqueWords.get(100));
        } else if (num < 1000) {
            int temp = num % 100;
            numInWords.append(uniqueWords.get((num / 100))).append(" ").append(uniqueWords.get(100)).append(" ").append("and").append(" ");
            if (temp <= 20) {
                numInWords.append(uniqueWords.get(temp));
            } else {
                numInWords.append(uniqueWords.get((temp / 10) * 10)).append(" ").append(uniqueWords.get(temp % 10));
            }
        }

        return numInWords.toString();
    }

    static public String calculateLargePower(long num, long pow) {
        String power = "1";
        for (int i = 1; i <= pow; i++) {
            power = multiplyTwoLargeNumberFaster(power, String.valueOf(num));
        }
        return power;
    }

    static String addLargeNumbersOfSameLength(String num1, String num2) {
        List<String> sum = new LinkedList<String>();
        // Assuming length of num1 and num2 are same.
        int carry = 0;
        for (int i = num1.length() - 1; i >= 0; i--) {
            int temp1 = num1.charAt(i) - 48;
            int temp2 = num2.charAt(i) - 48;
            int tempSum = temp1 + temp2 + carry;
            sum.add(String.valueOf(tempSum % 10));
            carry = tempSum / 10;
        }
        if (carry > 0) {
            sum.add(String.valueOf(carry));
        }
        StringBuilder finalsum = new StringBuilder();
        for (int i = sum.size() - 1; i >= 0; i--) {
            finalsum.append(Integer.parseInt(sum.get(i)));
        }

        return finalsum.toString();
    }

    static public String addLargeNumbersOfSameLengthUseBlock(String num1, String num2) {
        // StringBuilder sum = new StringBuilder();
        List<Integer> sum = new LinkedList<Integer>();
        int blockSize = String.valueOf(Integer.MAX_VALUE).length() - 1;
        int lengthOfNumber = num1.length();
        if (lengthOfNumber <= blockSize)
            return String.valueOf(Integer.parseInt(num1)+Integer.parseInt(num2));
        // Assuming length of num1 and num2 are same.
        int carry = 0;
        for (int i = lengthOfNumber - 1; i >= 0; i -= blockSize) {
            int startIndex = i - blockSize + 1;
            if (startIndex < 0) {
                startIndex = 0;
            }
            String tempNum1 = num1.substring(startIndex, i + 1);
            String tempNum2 = num2.substring(startIndex, i + 1);
            String tempSum = String.valueOf(Integer.parseInt(tempNum1) + Integer.parseInt(tempNum2)
                    + carry);
            if (tempSum.length() > blockSize && startIndex != 0) {
                carry = 1;
                tempSum = tempSum.substring(1);
            } else {
                carry = 0;
            }
            sum.add(0, Integer.parseInt(tempSum));
        }
        StringBuilder finalSum = new StringBuilder();
        for (Integer integer : sum) {
            finalSum.append(integer);
        }
        return finalSum.toString();
    }

    static public String addTwoLargeNumbers(String num1, String num2) {
        if (num1.length() == num2.length())
            return addLargeNumbersOfSameLengthUseBlock(num1, num2);
        else
            return addLargeNumbersOfDifferentLength(num1, num2);
    }

    private static String addLargeNumbersOfDifferentLength(String num1, String num2) {
        int length1 = num1.length();
        int length2 = num2.length();
        StringBuilder newNum = new StringBuilder();
        String sum = "";
        if (length1 > length2) {
            for (int i = 0; i < length1 - length2; i++) {
                newNum.append("0");
            }
            newNum.append(num2);
            sum = addLargeNumbersOfSameLengthUseBlock(num1, newNum.toString());
        } else {
            for (int i = 0; i < length2 - length1; i++) {
                newNum.append("0");
            }
            newNum.append(num1);
            sum = addLargeNumbersOfSameLengthUseBlock(newNum.toString(), num2);
        }
        return sum;
    }

    static public long getLCM(long lcm2, long b) {
        long lcm = lcm2 * b;
        long gcd = getGCD(lcm2, b);
        lcm = lcm / gcd;
        return lcm;
    }

    static public long getGCD(long lcm2, long b) {
        int gcd = 1;
        if (lcm2 == 0 || b == 0)
            return 1;
        else if (lcm2 == 1 || b == 1)
            return 1;
        else {
            if (lcm2 % b == 0)
                return b;
            else if (b % lcm2 == 0)
                return lcm2;
            else if (lcm2 > b)
                return getGCD(lcm2 % b, b);
            else if (lcm2 < b)
                return getGCD(lcm2, b % lcm2);
        }
        return gcd;
    }

    static public boolean isPrime(long n) {
        boolean isPrime = true;
        if (1 == n) {
            isPrime = false;
        } else if (2 == n) {
            isPrime = true;
        } else if (n % 2 == 0) {
            isPrime = false;
        } else {
            double sqrt = Math.sqrt(n);
            for (int i = 3; i <= sqrt; i += 2) {
                if (n % i == 0) {
                    // System.out.println(n+" is not a prime number.Divisible by "+i);
                    isPrime = false;
                    break;
                }
            }
        }
        /*
         * if(true == isPrime){ System.out.println(n +" is a prime number"); }
         */
        return isPrime;
    }

    public static boolean isPalindrome(String inputNumber) {
        boolean isPalindrome = true;
        String num1 = new StringBuilder(inputNumber).reverse().toString();
        if (!num1.equals(inputNumber)) {
            isPalindrome = false;
        }
        return isPalindrome;
    }

    static public boolean isPalindrome(int n) {
        return isPalindrome(String.valueOf(n));
    }

    static public int getNumOfDigits(Long number) {
        int digitsCount = 0;
        while (number > 0) {
            number = number / 10;
            digitsCount++;
        }
        return digitsCount;
    }

    static public long getNthPrime(int n) {
        long[] primes = getListOfFirstNPrimes(n);
        return primes[n - 1];
    }

    static public List<Long> getListOfPrimesLessThanN(int n) {
        List<Long> primes = new LinkedList<Long>();
        if (n >= 2) {
            primes.add(2l);
            long j = 3;
            if (n > 2) {
                for (; j <= n; j++) {
                    boolean isPrime = true;
                    long temp = primes.get(0);
                    for (int k = 1; temp <= Math.sqrt(j); k++) {
                        if (j % temp == 0) {
                            isPrime = false;
                            break;
                        }
                        temp = primes.get(k);
                    }
                    if (true == isPrime && j <= n) {
                        primes.add(j);
                    }
                    if (j > n) {
                        break;
                    }
                }
            }

        }
        return primes;
    }

    static public long[] getListOfFirstNPrimes(int n) {
        long primes[] = new long[n];
        primes[0] = 2;
        long j = 3;
        for (int i = 1; i < n; j++) {
            boolean isPrime = true;
            for (int k = 0; primes[k] <= Math.sqrt(j); k++) {
                long temp = primes[k];
                if (j % temp == 0) {
                    isPrime = false;
                    break;
                }
            }
            if (true == isPrime) {
                primes[i++] = j;
            }
        }
        return primes;
    }

    static public int getNumOfFactors(long n) {
        if (n == 1)
            return 1;
        else if (isPrime(n))
            return 2;
        else {
            int numOfFactors = 1;
            List<Long> primeFactors = getPrimeFactors(n);
            int[] primeFactorsPowers = new int[primeFactors.size()];
            int k = 0;
            for (Long long1 : primeFactors) {
                long temp = n;
                int count = 1;
                while (0 == temp % long1) {
                    temp = temp / long1;
                    count++;
                }
                primeFactorsPowers[k++] = count;
            }
            if (primeFactors.size() == 0)
                return 2;
            for (int i : primeFactorsPowers) {
                numOfFactors *= i;
            }
            return numOfFactors;
        }

    }

    public static List<Long> getPrimeFactors(long n) {
        List<Long> primeFactors = new LinkedList<Long>();
        int sqrt = (int) Math.sqrt(n);
        // List<Long> primes_Less_Than_N = list_Of_Primes_Less_Than_N(sqrt);
        for (long temp = 2; temp <= sqrt; temp++) {
            if (n % temp == 0) {
                primeFactors.add(temp);
            }
        }
        List<Long> primeFactors2 = new LinkedList<Long>();
        for (Long long1 : primeFactors) {
            long temp = n / long1;
            if (false == primeFactors.contains(temp) && isPrime((int) temp)) {
                primeFactors2.add(temp);
            }
        }
        primeFactors.addAll(primeFactors2);
        primeFactors2.clear();
        for (Long long1 : primeFactors) {
            if (isPrime(long1) == true) {
                primeFactors2.add(long1);
            }
        }
        return primeFactors2;
    }

    public static List<Long> getAllFactors(long n) {
        List<Long> primeFactors = new LinkedList<Long>();
        primeFactors.add(1l);
        if (n != 1) {
            int sqrt = (int) Math.sqrt(n);
            for (long temp = 2; temp <= sqrt; temp++) {
                if (n % temp == 0) {
                    primeFactors.add(temp);
                }
            }
            List<Long> primeFactors2 = new LinkedList<Long>();
            for (int i = primeFactors.size() - 1; i >= 0; i--) {
                long long1 = primeFactors.get(i);
                long temp = n / long1;
                if (false == primeFactors.contains(temp)) {
                    primeFactors2.add(temp);
                }
            }
            primeFactors.addAll(primeFactors2);
        }

        return primeFactors;
    }

    static public List<Long> gePrimesLessThanN(int n) {
        List<Long> primes = new LinkedList<Long>();
        int[] numbers = new int[n+1];
        boolean[] isPrime = new boolean[n+1];
        for(int i=0;i<=n;i++){
            isPrime[i] = true;
        }
        for(int i=0;i<=n;i++){
            numbers[i] = i;
        }
        for(int i=2;i<=Math.sqrt(n);i++){
            for(int j=2;i*j<=n;j++) {
                isPrime[i*j] = false;
            }
        }
        for(int i=2;i<=n;i++){
            if(isPrime[i] == true)
                primes.add((long)i);
        }
        return primes;
    }

    static public List<Long> gePrimesLessThanNGreaterThanM(long M, long N) {
        if(M==1)
            M=2;
        List<Long> primes = new LinkedList<Long>();
        int totalNumbers = (int)(N-M+1);
        long[] numbers = new long[totalNumbers];
        boolean[] isPrime = new boolean[totalNumbers];
        for(int i=0;i<totalNumbers;i++) {
            isPrime[i] = true;
        }
        for(int i=0;i<totalNumbers;i++){
            numbers[i] = (M+i);
        }
        for(int i=2;i<=Math.sqrt(N);i++){
            for(int j=Math.max(2,(int)(M/i));i*j<=N;j++) {
                if(i*j<M)
                    continue;
                else
                    isPrime[(int)((i*j)-M)] = false;
            }
        }
        for(int i=0;i<totalNumbers;i++){
            if(isPrime[i] == true)
                primes.add(numbers[i]);
        }
        return primes;
    }

    public static void main(String[] args) {
        System.out.println(getFactorialUsingMultiplication(100));
    }

    private static boolean isPrime(int n) {
        return isPrime((long) n);
    }

    static public String getFactorialUsingSum(int n) {
        String factorial = "1";
        for (int i = 1; i <= n; i++) {
            String temp = factorial;
            for (int j = 1; j < i; j++) {
                factorial = addTwoLargeNumbers(factorial, temp);
            }
        }
        return factorial;
    }

    static public String getFactorialUsingMultiplication(int n) {
        String factorial = "1";
        for (int i = 1; i <= n; i++) {
            factorial = multiplyTwoLargeNumberFaster(factorial, String.valueOf(i));
        }
        return factorial;
    }

    static public List<Long> getProperDivisor(long n) {
        List<Long> allFactors = getAllFactors(n);
        allFactors.remove(allFactors.size() - 1);
        return allFactors;
    }

    static public String multiplyTwoLargeNumberFaster(String num1, String num2) {
        int length1 = num1.length();
        int length2 = num2.length();
        if (length1 > length2) {
            String temp = num1;
            num1 = num2;
            num2 = temp;
            length1 = num1.length();
            length2 = num2.length();
        }
        String partialMulti[] = new String[length2];
        String[] multiplications = new String[10];
        for (int i = length2 - 1, k = 0; i >= 0; i--, k++) {
            int temp1 = num2.charAt(i) - 48;
            int carry = 0;
            StringBuilder sb = new StringBuilder();
            // Max no. of different digits in multiplicand can be 10.
            // So storing multiplication of multiplicant by each digit to avoid calculation again
            // and again
            if (multiplications[temp1] != null && !multiplications[temp1].isEmpty()) {
                sb.append(multiplications[temp1]);
            } else {
                for (int j = length1 - 1; j >= 0; j--) {
                    int temp2 = num1.charAt(j) - 48;
                    int multi = temp2 * temp1 + carry;
                    sb.append(multi % 10);
                    carry = multi / 10;
                }
                if (carry != 0) {
                    sb.append(carry);
                }
                sb = sb.reverse();
                multiplications[temp1] = sb.toString();
            }

            for (int l = 0; l < k; l++) {
                sb.append(0);
            }
            partialMulti[k] = sb.toString();
        }
        String multiplication = "";
        for (String partial : partialMulti) {
            multiplication = addTwoLargeNumbers(multiplication, partial);
        }
        return multiplication;
    }

    static public String getFibonacciNthTerm(int n) {
        List<String> terms = getFibonacciSeriesNTerms(n);
        return terms.get(n - 1);
    }

    static public List<String> getFibonacciSeriesNTerms(int n) {
        List<String> series = new LinkedList<String>();
        String nthTerm = "";
        String f0 = "1";
        String f1 = "1";
        if (n == 1) {
            series.add(f0);
        } else if (n == 2) {
            series.add(f0);
            series.add(f1);
        } else {
            series.add(f0);
            series.add(f1);
            for (int i = 1; i < n - 1; i++) {
                nthTerm = addTwoLargeNumbers(f0, f1);
                series.add(nthTerm);
                f0 = f1;
                f1 = nthTerm;
            }
        }
        return series;
    }

    // Assuming sorted permutations are there
    public static String getNthPermutation(int n, List<Integer> digits) {
        List<Integer> digits1 = new LinkedList<Integer>();
        digits1.addAll(digits);
        int location = n - 1;
        int digitsCount = digits1.size();
        StringBuilder number = new StringBuilder();
        for (int i = 0; i < digitsCount; i++) {
            String factorial = NumberUtil.getFactorialUsingMultiplication(digitsCount - i - 1);
            int index = Integer.parseInt(getQuotientByDividing(String.valueOf(location), factorial));
            number.append(String.valueOf(digits1.get(index)));
            digits1.remove(index);
            location = location - index * Integer.parseInt(factorial);
        }
        return number.toString();
    }

    public static String subtractTwoNumbers(String num1, String num2) {
        String result = "";
        int length1 = num1.length();
        int length2 = num2.length();
        if (length1 == length2) {
            result = subTractTwoNumbersOfSameLength(num1, num2, length1);
        } else {
            result = subTractTwoNumbersOfDifferentLength(num1, num2, length1, length2);
        }
        return result;
    }

    private static String subTractTwoNumbersOfDifferentLength(String num1, String num2, int length1, int length2) {
        String result = "";
        StringBuilder newNum = new StringBuilder();
        if (length1 > length2) {
            for (int i = 0; i < length1 - length2; i++) {
                newNum.append("0");
            }
            newNum.append(num2);
            result = subTractTwoNumbersOfSameLength(num1, newNum.toString(), length1);
        } else {
            for (int i = 0; i < length2 - length1; i++) {
                newNum.append("0");
            }
            newNum.append(num1);
            result = subTractTwoNumbersOfSameLength(newNum.toString(), num2, length2);
        }
        return result;
    }

    public static boolean isResultPositive(String num1, String num2, int length) {
        for (int i = 0; i < length; i++) {
            if (num1.charAt(i) > num2.charAt(i))
                return true;
            if (num1.charAt(i) < num2.charAt(i))
                return false;
            else {
                continue;
            }
        }
        return true;
    }

    private static boolean isResultPositive(String num1,String num2,int length1,int length2){
        StringBuilder newNum= new StringBuilder();
        if (length1 > length2) {
            for (int i = 0; i < length1 - length2; i++) {
                newNum.append("0");
            }
            newNum.append(num2);
            return isResultPositive(num1, newNum.toString(), length1);
        } else if(length2 > length1) {
            for (int i = 0; i < length2 - length1; i++) {
                newNum.append("0");
            }
            newNum.append(num1);
            return isResultPositive(newNum.toString(), num2, length2);
        } else
            return isResultPositive(num1, num2, length1);
    }

    private static String subTractTwoNumbersOfSameLength(String num1, String num2, int length) {
        // subtract num2 from num1(num1 -num2)
        StringBuilder result = new StringBuilder();
        int carry = 0;
        // if result is not positive then swap numbers to make it positive
        boolean resultPositive = isResultPositive(num1, num2, length);
        if (resultPositive == false) {
            String temp = num1;
            num1 = num2;
            num2 = temp;
        }
        for (int i = length - 1; i >= 0; i--) {
            int temp = 0;
            int digit1 = num1.charAt(i) - 48;
            int digit2 = num2.charAt(i) - 48;
            if (digit1 >= digit2) {
                if (carry == 1) {
                    digit1--;
                    carry = 0;
                    // when digit1(before subtracting the carry) and digit2 are equal
                    if (digit1 + 1 == digit2) {
                        digit1 += 10;
                        carry = 1;
                    }
                }
                temp = digit1 - digit2;
            } else {
                if (carry == 0) {
                    carry = 1;
                    digit1 += 10;
                } else {
                    digit1 = digit1 - 1 + 10;
                }
                temp = digit1 - digit2;
            }
            result.append(temp);
        }
        result = removeLeadingZeroes(result);
        if (resultPositive == false) {
            result.append("-");
        }
        result = result.reverse();
        return result.toString();
    }

    public static String getQuotientByDividing(String dividend,String divisor){
        String[] divisionResult = divideTwoNumbers(dividend, divisor);
        return divisionResult[0];
    }

    public static String getRemainderByDividing(String dividend,String divisor){
        String[] divisionResult = divideTwoNumbers(dividend, divisor);
        return divisionResult[1];
    }

    public static String[] divideTwoNumbers(String dividend, String divisor) {
        StringBuilder result = new StringBuilder();
        boolean done = false;
        int length = divisor.length();
        int index=length;
        int dividendLength = dividend.length();
        if(false ==  isResultPositive(dividend, divisor, dividendLength,length))
            return new String[]{"0",dividend};
        String temp = dividend.substring(0,length);
        while(done == false){
            while(false == isResultPositive(temp,divisor,temp.length(),length)){
                result.append("0");
                if(index >=dividendLength){
                    break;
                }
                temp = temp + dividend.substring(index, index+1);
                index++;
            }
            int count =0;
            while(true == isResultPositive(temp, divisor,temp.length(),length)){
                temp = subtractTwoNumbers(temp, divisor);
                count++;
            }
            if(temp.equalsIgnoreCase("0")){
                temp = "";
            }
            if(count >0){
                result.append(count);
            }
            if(index >= dividendLength){
                done = true;
                break;
            }else{
                temp = temp + dividend.substring(index, index+1);
                index++;
            }

        }
        return new String[]{removeLeadingZeroes(result.reverse()).reverse().toString(),temp};
    }

    private static StringBuilder removeLeadingZeroes(StringBuilder result) {
        int i = result.length() - 1;
        for (i = result.length() - 1; i > 0; i--) {
            if (result.charAt(i) != '0') {
                break;
            }
        }
        result.replace(i + 1, result.length(), "");
        return result;
    }

    public static Long[] getDigitsInNumber(Long Number) {
        List<Long> digits = new LinkedList<Long>();
        if (Number == 0) {
            digits.add(0l);
        } else {
            while (Number > 0) {
                digits.add(Number % 10);
                Number = Number / 10;
            }
        }
        Long[] digitsArray = new Long[digits.size()];
        for (int i = 0; i < digits.size(); i++) {
            digitsArray[i] = digits.get(i);
        }
        return digitsArray;
    }

    public static long[] getAllCircularRotations(Long number) {
        int digitsinNumber = getNumOfDigits(number);
        long[] numbers = new long[digitsinNumber];
        long tenthPower = (long)Math.pow(10, digitsinNumber - 1);
        long numberCopy = number;
        for (int i = 0; i < digitsinNumber; i++) {
            long num1 = numberCopy % tenthPower;
            long num2 = numberCopy / tenthPower;
            numberCopy = num1 * 10 + num2;
            numbers[i] = numberCopy;
        }
        return numbers;
    }

    public static boolean isAllDigitsNine(Long[] digits) {
        for (int i = 0; i < digits.length; i++)
            if (digits[i] != 9)
                return false;
        return true;
    }

    public static long getNextPalindrome(long number) {
        Long[] digits = getDigitsInNumber(number);
        int len = digits.length;
        if (len == 1 && digits[0] != 9)
            return digits[0] + 1;
        if (isAllDigitsNine(digits)) {
            int num = 10;
            for (int i = 0; i < len - 1; i++) {
                num *= 10;
            }
            num += 1;
            return num;
        }
        int mid = len / 2;
        int i = mid - 1;
        int j = len % 2 == 1 ? (mid + 1) : mid;
        while (i >= 0 && digits[i] == digits[j]) {
            i--;
            j++;
        }
        boolean isleftSmall = false;
        if (i < 0 || digits[i] < digits[j]) {
            isleftSmall = true;
        }
        if (!isleftSmall) {
            while (i >= 0) {
                digits[j++] = digits[i--];
            }
        } else {
            long carry = 1l;
            i = mid - 1;
            if (len % 2 != 0) {
                digits[mid] += carry;
                carry = digits[mid] / 10;
                digits[mid] = digits[mid] % 10;
                j = mid + 1;
            } else {
                j = mid;
            }
            while (i >= 0) {
                digits[i] += carry;
                carry = digits[i] / 10;
                digits[i] = digits[i] % 10;
                digits[j++] = digits[i--];
            }
        }
        long ret = 0l;
        int x = 0;
        for (x = 0; x < len - 1; x++) {
            ret += digits[x];
            ret *= 10;
        }
        ret += digits[x];
        return ret;
    }

    public static boolean doesNumberContainEvenNumber(Long number) {
        if (number == 0)
            return true;
        while (number > 0) {
            long num = number % 10;
            number = number / 10;
            if (num % 2 == 0)
                return true;
        }
        return false;
    }

    /* public static long getNextPrime */
}

    static class InputReader {

        private InputStream stream;

        private byte[] buf = new byte[1024];

        private int curChar;

        private int numChars;

        private SpaceCharFilter filter;

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

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

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

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

        public long readLong() {
            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 static boolean isWhitespace(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

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

    static class OutputWriter {
        private final PrintWriter writer;

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

        public void printLine(String string) {
            writer.println(string);
        }

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

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

    }

    public static void main(String[] args) {
        InputReader ir = new InputReader(System.in);
        OutputWriter ow = new OutputWriter(System.out);
        String[][] possibilities = {
                {
                        "C", "ODEFORCES"
                }, {
                        "CO", "DEFORCES"
                }, {
                        "COD", "EFORCES"
                }, {
                        "CODE", "FORCES"
                }, {
                        "CODEF", "ORCES"
                }, {
                        "CODEFO", "RCES"
                }, {
                        "CODEFOR", "CES"
                }, {
                        "CODEFORC", "ES"
                }, {
                        "CODEFORCE", "S"
                },
        };
        /*
        int length = 10;
        StringBuilder codeForces = new StringBuilder("CODEFORCES");
        for (int i = 0; i < length-1; i++) {
            System.out.println("{\""+codeForces.substring(0, i + 1)+"\","+"\""+codeForces.substring(i+1, length)+"\"},");

        }*/
        String charsequence = "CODEFORCES";
        String read = ir.next();
        boolean possible = false;
        if(read.length() < 10){
            possible = false;
        } else if (read.contains(charsequence)) {
            int index = read.indexOf(charsequence);
            if (index == 0 || index == read.length() - charsequence.length())
                possible = true;
        }
		if (possible == false && read.length() >=10) {
            for (int i = 0; i < 9; i++) {
                boolean firstMatch = possibilities[i][0].equalsIgnoreCase(read.substring(0,
                        possibilities[i][0].length()));
                boolean secondMatch = possibilities[i][1].equalsIgnoreCase(read.substring(
                        read.length() - possibilities[i][1].length(), read.length()));
                if (firstMatch && secondMatch) {
                    possible = true;
                    break;
                }

                /*
                 * int first = read.indexOf(possibilities[i][0]); int second =
                 * read.indexOf(possibilities[i][1], first); if (first != -1 && second != -1 &&
                 * second > first) {
                 * System.out.println(possibilities[i][0]+" "+possibilities[i][1]+"first="
                 * +first+" second"+second); possible = true; break; }
                 */
            }
        }
        if (possible)
            ow.printLine("YES");
        else
            ow.printLine("NO");
        ow.close();
    }

}


import java.util.Scanner;

/**
 *
 * @author izharishaksa
 */
public class CuttingBanner {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.nextLine();
        String code = 'CODEFORCES';
        int counter = 0;
        for (int i = 0; i < s.length() && counter < 10; i++) {
            if (s.charAt(i) == code.charAt(counter)) {
                counter++;
            }
        }
        if (counter == 10) {
            System.out.println("YES");
        } else {
            System.out.println("NO");
        }
    }

}


import java.util.Scanner

public class  Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        System.out.println(solve(in.next())? "YES" : "NO");
        in.close();
    }

    public static boolean solve(String banner) {
        int len = banner.length();

        if(len < 10) return false;

        String codeForces = "CODEFORCES";

        if(len == 10) return codeForces.equals(banner);

        for(int cut = 1; cut < len; cut++) {
            if(len - cut != 10)  continue;

            for(int i = 0; i <= len - cut; i++) {
                String tmp = banner.substring(0, i).concat(banner.substring(i + cut));
                if(tmp.equals(codeForces)) return true;
            }
        }

        return false;
    }
}


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

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Fred Zhang
 */
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) {
            String input = in.readLine();
            char[] chars = new char[4];
            for (int i = 0; i < input.length(); i++) {
                if (input.charAt(i) != '!')
                    chars[i % 4] = input.charAt(i);
            }

            int r = 0;
            int b = 0;
            int y = 0;
            int g = 0;
            for (int i = 0; i < input.length(); i++) {
                if (input.charAt(i) == '!') {
                    if (chars[i % 4] == 'R')
                        r++;
                    if (chars[i % 4] == 'B')
                        b++;
                    if (chars[i % 4] == 'Y')
                        y++;
                    if (chars[i % 4] == 'G')
                        g++;
                }
            }

            out.print(r + " " + b + " " + y + " " + g);
        }

    }

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

    }

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

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

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

        private String readLine0() {
            StringBuilder buf = new StringBuilder();
            int c = read();
            while (c != '\n' && c != -1) {
                if (c != '\r') {
                    buf.appendCodePoint(c);
                }
                c = read();
            }
            return buf.toString();
        }

        public String readLine() {
            String s = readLine0();
            while (s.trim().length() == 0) {
                s = readLine0();
            }
            return s;
        }

    }
}


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

public class BComp {

    public static void main(String[] args) {
        AComp.FastScanner fc = new AComp.FastScanner();
        String colors = fc.nextToken();
        String [] values = new String[4];
        for (int i=0;i<4; i++) {
            values[i] = findColor(colors, i, colors.length());
        }
        values = check(values);
        int map [] = {0,0,0,0};
        int p = 0;
        for (int i=0;i<colors.length();i++) {
            if ("!".equals(String.valueOf(colors.charAt(i)))) {
                map[p]++;
            }
            if (p == 3){
                p = 0;
            } else {
                p++;
            }
        }
        System.out.println(map[getPositionNumber(values, "R")] + " " + map[getPositionNumber(values, "B")] + " " + map[getPositionNumber(values, "Y")] + " " + map[getPositionNumber(values, "G")]);
    }

    private static int getPositionNumber(String [] values, String value) {
        for (int i=0;i<4;i++) {
            if (value.equals(values[i])) {
                return i;
            }
        }
        return 0;
    }

    private static String[] check(String[] values) {
        int position = 0;
        boolean red = false, blue = false, yellow = false, green = false;
        for (;position<4; position++) {
            String value = values[position];
            if ("!".equals(value)) {
                break;
            } else {
                if ("R".equals(value)) {
                    red = true;
                } else if ("B".equals(value)) {
                    blue = true;
                } else if ("Y".equals(value)) {
                    yellow = true;
                } else if ("G".equals(value)) {
                    green = true;
                }
            }
        }
        if (position != 4) {
            String value = "";
            if (!red) {
                value = "R";
            } else if (!blue) {
                value = "B";
            } else if (!yellow) {
                value = "Y";
            } else if (!green) {
                value = "G";
            }
            values[position] = value;
        }
        return values;
    }

    private static String findColor(String colors, int i, int len) {
        String value = String.valueOf(colors.charAt(i));
        if (!"!".equals(value)) {
            return value;
        } else if ((i + 4)>len) {
            return "!";
        } else {
            return findColor(colors, i+4, len);
        }
    }

    public static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner(String s) {
            try {
                br = new BufferedReader(new FileReader(s));
            } catch (FileNotFoundException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }

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

        String nextToken() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

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

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


import java.util.*;
import java.io.*;
public class garland
{
	public static void main(String[] args)throws IOException {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		PrintWriter pw=new PrintWriter(System.out);
		String s=br.readLine();
		int l=s.length();
		int f,s,th,fo;
		int count[]=new int[4];
		for(int i=0;i<l;i++)
		{
			j=j%4;
			if(s.charAt(j)!='!')
				count[j]++;

		}
			for(int j=0;j<l;j++)
			{
				if(s.charAt(j)=='R')
				{
					j%=4;
					pw.print(count[j]+" ")
					break;
				}
			}
			for(int j=0;j<l;j++)
			{
				if(s.charAt(j)=='B')
				{
					j%=4;
					pw.print(count[j]+" ")
					break;
				}
			}
			for(int j=0;j<l;j++)
			{
				if(s.charAt(j)=='Y')
				{
					j%=4;
					pw.print(count[j]+" ")
					break;
				}
			}
			for(int j=0;j<l;j++)
			{
				if(s.charAt(j)=='G')
				{
					j%=4;
					pw.print(count[j]+" ")
					break;
				}
			}
			pw.flush();

	}
}


package main;

import FastIO.InputReader;
import FastIO.OutputWriter;

public class TaskB {
    public void solve(int testNumber, InputReader in, OutputWriter out) {
        String input = in.readLine();
        char[] chars = new char[4];
        for(int i = 0; i < input.length(); i++)
        {
            if(input.charAt(i) != '!')
                chars[i % 4] = input.charAt(i);
        }

        int r = 0;
        int b = 0;
        int y = 0;
        int g = 0;
        for(int i = 0; i < input.length(); i++)
        {
            if(input.charAt(i) == '!')
            {
                if(chars[i % 4] == 'R')
                    r++;
                if(chars[i % 4] == 'B')
                    b++;
                if(chars[i % 4] == 'Y')
                    y++;
                if(chars[i % 4] == 'G')
                    g++;
            }
        }

        out.print(r + " " + b + " " + y + " " + g);
    }
}


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

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

    static class ProblemARobbersWatch {
        int n;
        int m;
        int hour;
        int min;

        public void solve(int testNumber, InputReader in, PrintWriter out) {
            n = in.readInt();
            m = in.readInt();
            hour = (int) Math.floor(Math.log(n - 1) / Math.log(7)) + 1;
            min = (int) Math.floor(Math.log(m - 1) / Math.log(7)) + 1;
            int ans = go(0, 0, "");
            out.println(ans);
        }

        int go(int pos, int mask, String number) {
            if (pos == hour + min) {
                if (Integer.parseInt(number.substring(0, hour), 7) >= n) return 0;
                if (Integer.parseInt(number.substring(hour), 7) >= m) return 0;
                return 1;
            }

            int ans = 0;
            for (int i = 0; i < 7; i++) {

                if (((mask >> i) & 1) == 0) {
                    int tm = mask | (1 << i);
                    ans += go(pos + 1, tm, number + i);
                }
            }
            return ans;
        }

    }

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

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

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

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

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

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

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

        }

    }
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.Reader;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
import java.util.StringTokenizer;

// Codeforces Round #359 (Div. 2)
// Robbers' watch
public class Problem_686_C {

	private void doSolve(PrintWriter out) {

		int n = nextInt();
		int m = nextInt();

		Integer[] nBase7 = changeBaseFrom10(n - 1, 7);
		Integer[] mBase7 = changeBaseFrom10(m - 1, 7);

		int digitsN = nBase7.length;
		int digitsM = mBase7.length;

		int totalDigits = digitsN + digitsM;
		if (totalDigits > 7) {
			out.println("0");
			return;
		}

		int counter = 0;
		LinkedList<Integer> stack = new LinkedList<Integer>();
		while (true) {
			if (stack.size() < totalDigits) {
				stack.addLast( findNextDigit(stack, 0) );
			}
			else {
				if ( isValid( stack.subList(0, digitsN), nBase7 )
						&& isValid( stack.subList(digitsN, totalDigits), mBase7 ) ) {
					counter++;
				}

				while (true) {
					int currentDigit = stack.removeLast();
					Integer nextDigit = findNextDigit(stack, currentDigit + 1);
					if (nextDigit != null) {
						stack.addLast(nextDigit);
						break;
					}
					if (stack.isEmpty()) {
						break; // we are done!
					}
				}

				if (stack.isEmpty()) {
					break;
				}
			}
		}
		out.println(counter);
	}

	private Integer findNextDigit(List<Integer> digits, int startFrom) {
		for (int i = startFrom; i < 7; i++) {
			boolean used = false;
			for (int j : digits) {
				if (j == i) {
					used = true;
					break;
				}
			}
			if (!used) {
				return i;
			}
		}
		return null;
	}

	private boolean isValid(List<Integer> digits, Integer[] maxValue) {
		for (int i = 0; i < digits.size(); i++) {
			if (digits.get(i) == maxValue[i]) {
				continue;
			}
			return maxValue[i] > digits.get(i);
		}
		return true;
	}

	private Integer[] changeBaseFrom10(int decimal, int base) {
		List<Integer> result = new LinkedList<Integer>();
		while (decimal > 0) {
			result.add( decimal % base );
			decimal /= base;
		}
		Collections.reverse(result);
		return result.toArray(new Integer[result.size()]);
	}

	/* ========================================================= */

    private InputReader inputReader;

    public static void main(String[] args)
    {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        PrintWriter out = new PrintWriter(outputStream);
        Problem_686_C solver = new Problem_686_C();
        solver.solve(1, new InputStreamReader(inputStream), out);
        out.close();
    }

    public int nextInt() {
    	return inputReader.nextInt();
    }

    public String next() {
    	return inputReader.next();
    }

    public void solve(int test, Reader in, PrintWriter out)
    {
    	inputReader = new InputReader(in);
    	doSolve(out);

    }

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

        public InputReader(Reader reader) {
            this.reader = new BufferedReader(reader, 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 nextInt() {
            return Integer.parseInt(next());
        }

    }

}


/*Author LAVLESH*/
import java.util.*;
import java.io.*;
public class solution{
	static BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
	static StringTokenizer st=new StringTokenizer("");
	static int basechange(int n)
	{
		StringBuilder st=new StringBuilder("");
		while(n>0){
			st.append(n%7);n/=7;
		}
		st.append(n);
		return Integer.parseInt(st.reverse().toString());

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

	public static void main(String[]args)throws IOException{
         long ans=0;PrintStream op = System.out;
		 int n=Integer.parseInt(next());
		 int m=Integer.parseInt(next());
		int []a=new int[n];
		int []b=new int [m];
		for(int i=0;i<n;i++)
		{
			a[i]=basechange(i);//op.println(a[i]);
		}
		for(int i=0;i<m;i++)
		{
			 b[i]=basechange(i);
		}
		StringBuilder p=new StringBuilder().append(a[n-1]).append(b[m-1]);
		int l=p.length();
		for(int i=0;i<n;i++)
		{
			for(int j=0;j<m;j++)
			{
				StringBuilder s=new StringBuilder();
				s.append(a[i]);s.append(b[j]);
				while(s.length()<l) s.append("0",0,1);
				int f=0;
				String S=s.toString();int []x=new int[10];
				for(int k=0;k<S.length();k++)
				{
					int y=Integer.parseInt(""+s.charAt(k));
					x[y]++;
					if(x[y]>1)
{
	f=1;
}

				}
				if(f==0){ans++;f=0;}//System.out.println(s);}
			}
		}

		 op.println(ans);
		  op.close();
		}
	}


import java.io.*;
import java.util.*;
public final class code
// class code
// public class Solution
{
	static void solve()throws IOException
	{
		int n=nextInt();
		int m=nextInt();
		int d1=Math.ceil(Math.log(n)/Math.log(7));
		int d2=Math.ceil(Math.log(m)/Math.log(7));
		if(d1+d2>7)
		{
			out.println(0);
			return;
		}
		long c=0;
		for(int i=0;i<n;i++)
		{
			for(int j=0;j<m;j++)
			{
				int used[]=new int[7];
				for(int k=i;k>0;k=k/7)
					used[k%7]++;
				for(int k=j;k>0;k=k/7)
					used[k%7]++;
				boolean flag=false;
				for(int k=0;k<7;k++)
				{
					if(used[k]>1)
					{
						flag=true;
						break;
					}
				}
				if(flag==false)
					c++;
			}
		}
		out.println(c);
	}

	///////////////////////////////////////////////////////////
	static final long mod=(long)(1e9+7);
	// static final int inf=(int)(1e9);
	static final long inf=(long)(1e18);
	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 void debug(Object ... a)
	{
		System.out.print("> ");
		for(int i=0;i<a.length;i++)
			System.out.print(a[i]+" ");
		System.out.println();
	}
	static void debuga(int a[])
	{
		System.out.print("> ");
		for(int i=0;i<a.length;i++)
			System.out.print(a[i]+" ");
		System.out.println();
	}
	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();

		// int t=nextInt();
		// for(int i=1;i<=t;i++)
		// {
		// 	// out.print("Case #"+i+": ");
		// 	solve();
		// }

		out.close();
	}
}


import static java.lang.Math.PI;
import static java.lang.Math.acos;
import static java.lang.Math.cos;
import static java.lang.Math.sin;
import static java.lang.Math.sqrt;
import static java.lang.System.in;
import static java.lang.System.out;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.Scanner;

public class C14 {
	public static Scanner sc = new Scanner(in);
	StringBuilder sb = new StringBuilder();
	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	double eps = 0.0000001;
	public boolean checkR(P ver[]){
		for (int i=0; i<4; i++)
			if (Math.abs(P.arg(ver[i], ver[(i+1)%4], ver[(i+2)%4])-Math.PI/2)>eps &&
				Math.abs(P.arg(ver[i], ver[(i+1)%4], ver[(i+2)%4])-3*Math.PI/2)>eps) return false;
		for (int i=0; i<4; i++)
			if ( Math.abs(P.arg(ver[i], ver[(i+1)%4]))<eps) return true;
		return false;
	}
	public void run() throws IOException {
		String input;
		String[] inputArray;
		P [][] ver = new P [4][2];
		P [] apex = new P[4];
		for (int i=0; i<4; i++){
			input = br.readLine();
			inputArray = input.split(" ");
			int x = Integer.valueOf(inputArray[0]);
			int y = Integer.valueOf(inputArray[1]);
			ver[i][0] = new P(x,y);
			x = Integer.valueOf(inputArray[2]);
			y = Integer.valueOf(inputArray[3]);
			ver[i][1] = new P(x,y);
		}
		apex[0] = ver[0][0];
		apex[1] = ver[0][1];
		for (int i=1; i<4; i++)
			if (ver[i][0].equals(apex[1])) apex[2] = ver[i][1];
			else if (ver[i][1].equals(apex[1])) apex[2] = ver[i][0];
		for (int i=1; i<4; i++)
			if (ver[i][0].equals(apex[0])) apex[3] = ver[i][1];
			else if (ver[i][1].equals(apex[0])) apex[3] = ver[i][0];
		for (int i=0; i<4; i++){
			int num = 0;
			for (int j=0; j<4; j++){
				if (apex[i].equals(ver[j][0])) num++;
				if (apex[i].equals(ver[j][1])) num++;
			}
			if (num !=2) {
				ln("NO");
				return;
			}
		}
		if (checkR(apex)) ln("YES");
		else ln("NO");
	}

	public static void main(String[] args) throws IOException {
		new C14().run();
	}
	public static void ln(Object obj) {
		out.println(obj);
	}
	static class P{

			static final double EPS=1e-10;
			static int signum(double x){
				return x<-EPS?-1:x>EPS?1:0;
			}
		static Comparator<P> comp=new Comparator<P>(){
			public int compare(P p1, P p2) {
				return signum(p1.x-p2.x)!=0?signum(p1.x-p2.x):signum(p1.y-p2.y);
			}
		};
		public static  final P O=new P(0,0);
		final double x,y;
		P(double _x,double _y){
			x=_x;y=_y;
		}

		P add(P a){
			return new P(x+a.x,y+a.y);
		}
		P sub(P a){
			return new P(x-a.x,y-a.y);
		}
		P mul(P a){
			return new P(x*a.x-y*a.y,x*a.y+y*a.x);
		}
		P div(P a){
			double d2=a.dist2(O);
			return new P(dot(a,this)/d2,cross(a,this)/d2);
		}

		P conj(){
			return new P(x,-y);
		}

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

		static double cross(P a,P b){
			return  a.x*b.y-a.y*b.x;
		}

		double dist2(P p){
			return (x-p.x)*(x-p.x)+(y-p.y)*(y-p.y);
		}

		double dist(P p){
			return sqrt(dist2(p));
		}
		public double norm(){
			return dist(O);
		}

		static int ccw(P a,P b,P c){
			b=b.sub(a);c=c.sub(a);
			if(cross(b,c)>EPS)return 1;
			if(cross(b,c)<-EPS)return -1;
			if(dot(b,c)<-EPS)return 2;
			if(b.norm()<c.norm()-EPS)return -2;
			return 0;
		}

		static double arg(P o,P a){
			P dir=a.sub(o);
			double s=acos(dir.x/dir.norm());
			return dir.y>=0?s:2*PI-s;
		}

		static double arg(P a,P b, P c){
			double angleA = P.arg(a,b);
			double angleB = P.arg(b,c);
			double angle =  Math.PI+angleA-angleB;
			if (angle-2*Math.PI>EPS) angle-=2*Math.PI;
			if (angle<EPS) angle+=2*Math.PI;
			return angle;
		}

		P rotate(P o,double arg){
			return this.add(this.sub(o).mul(new P(cos(arg),sin(arg))));
		}

		static double S2(P a,P b,P o){
			return cross(a.sub(o),b.sub(o));
		}
		static double S(P a,P b,P o){
			return S2(a,b,o)/2;
		}

		static P polar(double abs,double arg){
			return new P(abs*cos(arg),abs*sin(arg));
		}

		static P proj(P p,P o){
			return o.mul(new P(dot(p,o)/o.norm(),0));
		}
		public boolean equals(Object obj) {
			if(obj instanceof P){
				P p=(P)obj;
				return signum(x-p.x)==0 && signum(y-p.y)==0;
			}
			return false;
		}
		public String toString(){
			return "("+x+","+y+")";
		}
	}
}


import java.awt.Point;
import java.util.Scanner;
public class fourSegments {
	 private static void swap(Point num1, Point num2) {

         Point temp = num1;
         num1 = num2;
         num2 = temp;
 }

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

	Point [][] hori= new Point[2][2];
	Point [][] vert= new Point[2][2];
	boolean checkdead=false;
	int num1=0; // horizental
	int num2=0; // vertical
	int width=0;
	int length=0;
	int bottom=0;
	for (int i=0;i<4;i++){
		Point[] seg= new Point[2];
		seg[0]=new Point(0,0);
		seg[1]=new Point(0,0);
	seg[0].x= input.nextInt();
	seg[0].y= input.nextInt();
	seg[1].x= input.nextInt();
	seg[1].y= input.nextInt();
	if (seg[0].x==seg[1].x){
		if ((seg[0].y>seg[1].y)&&(num2<2)){
		vert[num2][0]=seg[1];
		vert[num2][1]=seg[0];
		}
		else{
			vert[num2][0]=seg[0];
			vert[num2][1]=seg[1];
		}
		num2++;
	}
	else if ((seg[0].y==seg[1].y)&&(num1<2)){
		if (seg[0].x>seg[1].x){
			hori[num1][0]=seg[1];
			hori[num1][1]=seg[0];
			}
			else{
				hori[num1][0]=seg[0];
				hori[num1][1]=seg[1];
			}
		num1++;
	 }
	else
	{
		checkdead=true;
	}

	}
	if (checkdead) System.out.print("NO"); // there is line not // to x or y axis
	else{
		if ((num1==2)&&(num2==2)){
			if ((hori[0][0].x==hori[1][0].x) &&(hori[0][1].x==hori[1][1].x)&&(hori[0][0].x!=hori[0][1].x)&&(hori[0][0].y!=hori[1][0].y)){ //check the horizental
				width=Math.abs(hori[0][0].y-hori[1][0].y);
				length=Math.abs(hori[0][1].x-hori[0][0].x);
				if ((hori[0][0].y>hori[1][0].y)){
         				bottom=1;
				}  else {
					bottom=0;
				}

				if ((vert[0][0].y==vert[1][0].y) &&(vert[0][1].y==vert[1][1].y)&&(vert[0][0].y!=vert[0][1].y)&&(Math.abs(vert[0][0].x-vert[1][0].x)==length)){ // check vertical
					if ((vert[0][0].y==hori[bottom][0].y)&&(vert[0][1].y==(vert[0][0].y+width))){
						System.out.print("YES");
					}
					else checkdead=true;
				}
				else checkdead=true;
			}  //  bdayt awel if twela
			else{
				checkdead=true;
			}
		}
		else{
			checkdead=true;
		}

		if (checkdead) System.out.print("NO");
	}

  }

}


//package com.himanshu.practice.july17;

import lombok.AllArgsConstructor;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;

/**
 * Created by himanshubhardwaj on 18/07/18.
 */
public class FourSegments {
    public static void main(String[] args) throws IOException {
        int x1, y1, x2, y2;
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        ArrayList<Line> lines = new ArrayList<>();
        String str[];
        ArrayList<Point> points = new ArrayList<>();

        for (int i = 0; i < 4; i++) {
            str = br.readLine().split(" ");
            x1 = Integer.parseInt(str[0]);
            y1 = Integer.parseInt(str[1]);
            x2 = Integer.parseInt(str[2]);
            y2 = Integer.parseInt(str[3]);
            Line line = new Line(x1, y1, x2, y2);
            lines.add(line);
        }

        if (Line.isRectangle(lines)) {
            System.out.println("YES");
        } else {
            System.out.println("NO");
        }
    }
}

@ToString
@EqualsAndHashCode
class Line {
    @EqualsAndHashCode.Exclude
    Point p1;
    @EqualsAndHashCode.Exclude
    Point p2;
    @EqualsAndHashCode.Include
    float slope;
    @EqualsAndHashCode.Include
    float intercept;

    public Line(float slope, float intercept) {
        this.slope = slope;
        this.intercept = intercept;
    }

    public Line(int x1, int y1, int x2, int y2) {
        p1 = new Point(x1, y1);
        p2 = new Point(x2, y2);
        setSlopeAndInterSection();
    }

//    public boolean equals(Object anObject) {
//        boolean result = false;
//        if (anObject == this) {
//            result = true;
//        }
//
//        if (anObject instanceof Line) {
//            Line newLine = (Line) anObject;
//            if (newLine.intercept == this.intercept && newLine.slope == this.slope) {
//                result = true;
//            }
//
//        }
//
//        System.out.println(this + "\t" + anObject + "\t" + result);
//        return result;
//    }

    public void setSlopeAndInterSection() {
        if (this.p2.x != this.p1.x) {
            this.slope = (this.p2.y - this.p1.y) / (this.p2.x - this.p1.x);
            this.intercept = this.p1.y - slope * this.p1.x;
        } else {
            this.intercept = this.p1.x;
            this.slope = -1;
        }
    }

    //returns trye is line intersection forms a rectangle
    public static boolean isRectangle(ArrayList<Line> lines) {
        if (!checkIfParallelToAxis(lines)) {
            return false;
        }

        double d[] = new double[2];
        d[0] = -1;
        d[1] = -1;
        int count = 0;
        for (int i = 0; i < lines.size(); i++) {
            for (int j = i + 1; j < lines.size(); j++) {
                if (lines.get(i).slope == lines.get(j).slope) {
                    if (count == 2) {
                        return false;
                    }
                    d[count] = Math.abs(lines.get(i).intercept - lines.get(j).intercept);
                    count++;
                }
            }
        }

        if (d[0] > 0 || d[1] > 0) {
            return true;
        }
        return false;
    }

    private static boolean checkIfParallelToAxis(ArrayList<Line> lines) {
        int slopeZero = 0;
        int slopeINF = 0;

        if (lines.size() != 4) {
            return false;
        }
        HashMap<Point, Integer> occurence = new HashMap<>();

        for (int i = 0; i < lines.size(); i++) {
            //testHashMap(occurence, lines.get(i).p1);
            if (occurence.containsKey(lines.get(i).p1)) {
                occurence.put(lines.get(i).p1, 1 + occurence.get(lines.get(i).p1));
            } else {
                occurence.put(lines.get(i).p1, 1);
            }

            //testHashMap(occurence, lines.get(i).p2);

            if (occurence.containsKey(lines.get(i).p2)) {
                occurence.put(lines.get(i).p2, 1 + occurence.get(lines.get(i).p2));
            } else {
                occurence.put(lines.get(i).p2, 1);
            }

            for (int j = i + 1; j < lines.size(); j++) {
                if (lines.get(i).equals(lines.get(j))) {
                    return false;
                }
            }
        }

//        System.out.println(occurence);

        for (Map.Entry<Point, Integer> entry : occurence.entrySet()) {
            if (entry.getValue() != 2) {
                return false;
            }
        }

        for (Line l : lines) {
            //System.out.println(l + "..");
            if (l.slope == 0) {
                slopeZero++;
            } else if (l.slope == -1) {
                slopeINF++;
            } else {
                return false;
            }
        }

        if (slopeINF == 2 && slopeZero == 2) {
            return true;
        }

        return false;
    }

    public static void testHashMap(HashMap<Point, Integer> occurence, Point p1) {
        System.out.println(occurence + "\t\t" + p1 + "\t\t" + occurence.containsKey(p1));
    }
}

@AllArgsConstructor
@ToString
@EqualsAndHashCode
class Point {
    @EqualsAndHashCode.Include
    float x;
    @EqualsAndHashCode.Include
    float y;

//    public boolean equals(Object anObject) {
//        boolean result = false;
//        if (this == anObject) {
//            result = true;
//        }
//
//        if (anObject instanceof Point) {
//            Point newPoint = (Point) anObject;
//
//            if (Float.valueOf(newPoint.x).equals(this.x) && Float.valueOf(newPoint.y).equals(this.y)) {
//                result = true;
//            }
//        }
//
//        System.out.println(this + "\t" + anObject + "\t" + result);
//        return false;
//    }
//

}


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

        Point[] points = new Point[8];
        for (int i = 0; i < points.length; i++){
            double x = leer.nextDouble();
            double y = leer.nextDouble();
            points[i] = new Point(x,y);
        }
        solve(points);
    }
    public static void solve(Point[] points){
        Segment[] segments = createSegments(points);

        if(correctPoints(points)){
            double distSegments[] = calcDistances(segments);

            boolean isLine = isLine(distSegments);
            //System.out.println("isLine = "+isLine);

            if(!isLine){
                boolean pairDistances = pairDistances(distSegments);
                //System.out.println("pairDistances = "+pairDistances);

                if(pairDistances){
                    boolean segmentParallel = segmentParallel(segments);
                    //System.out.println("segmentParallel = "+segmentParallel);

                    if(segmentParallel){
                        boolean isSameCenter = isSameCenter(segments);
                        //System.out.println("isSameCenter = "+isSameCenter);

                        if(isSameCenter){
                            boolean isRombo = isRombo(points);
                            if(!isRombo)
                                System.out.println("YES");
                            else
                                System.out.println("NO");
                        }
                        else
                            System.out.println("NO");
                    }
                    else
                        System.out.println("NO");
                }
                else
                    System.out.println("NO");
            }
            else
                System.out.println("NO");
        }
        else
            System.out.println("NO");
    }
    public static boolean isRombo(Point[] points){
        Point[] pts = differentPoints(points);

        int cont = 0;

        for (int i = 0; i < pts.length; i++) {
            for (int j = i+1; j < pts.length; j++) {
                if(pts[i].x != pts[j].x && pts[i].y != pts[j].y)
                    cont++;
            }
        }
        if(cont==4)
            return true;
        else
            return false;
    }
    public static boolean isSameCenter(Segment[] segments){

        boolean isSameC = true;
        Point mP1 = middlePoint(segments[0].p1, segments[0].p2);
        Point mP2 = middlePoint(segments[1].p1, segments[1].p2);
        Point mP3 = middlePoint(segments[2].p1, segments[2].p2);
        Point mP4 = middlePoint(segments[3].p1, segments[3].p2);

        Point ptoInter = pointIntersection(mP1, mP4, mP2, mP3);

        if(ptoInter==null){
            ptoInter = pointIntersection(mP1, mP3, mP2, mP4);
            if(ptoInter == null){
                ptoInter = pointIntersection(mP1, mP2, mP4, mP3);
                if(ptoInter == null)
                    isSameC = false;
            }
        }

        if(isSameC){
            Point pts[] = new Point[8];
            pts[0] = segments[0].p1; pts[1] = segments[0].p2;
            pts[2] = segments[1].p1; pts[3] = segments[1].p2;
            pts[4] = segments[2].p1; pts[5] = segments[2].p2;
            pts[6] = segments[3].p1; pts[7] = segments[3].p2;

            Point[] difPoints = differentPoints(pts);

            double d1 = dist2Points(ptoInter, difPoints[0]);
            double d2 = dist2Points(ptoInter, difPoints[1]);
            double d3 = dist2Points(ptoInter, difPoints[2]);
            double d4 = dist2Points(ptoInter, difPoints[3]);
//
//            System.out.println();
//            System.out.println("ptoInter = "+ptoInter);
//            System.out.println("d1 = "+d1);
//            System.out.println("d2 = "+d2);
//            System.out.println("d3 = "+d3);
//            System.out.println("d4 = "+d4);

            if(d1 == d2 && d2 == d3 && d3 == d4)
                isSameC = true;
            else
                isSameC = false;
        }

        return isSameC;
    }
    public static double dist2Points(Point A, Point B){
        double d1 = A.x - B.x;
        double d2 = A.y - B.y;

        double dist = Math.sqrt(d1*d1 + d2*d2);
        double distRound = Math.round(dist*Math.pow(10, 4));
        dist = distRound/Math.pow(10, 4);

        return dist;
    }
    public static Point middlePoint(Point A, Point B){
        double x = (A.x + B.x)/2;
        double y = (A.y + B.y)/2;
        return new Point(x,y);
    }
     public static Point pointIntersection(Point PA, Point PB, Point PC, Point PD){
        double A1 = PB.y - PA.y;
        double B1 = PA.x - PB.x;
        double C1 = A1 * PA.x + B1 * PA.y;

        double A2 = PD.y - PC.y;
        double B2 = PC.x - PD.x;
        double C2 = A2 * PC.x + B2 * PC.y;

        double det  = A1*B2 - A2*B1;
        if(det==0){//Lineas Paralelas
            return null;
        }
        else{
            double x = (B2*C1 - B1*C2)/det;
            double y = (A1*C2 - A2*C1)/det;
            return new Point(x,y);
        }
    }

    public static boolean pairDistances(double[] distances){
        boolean pair = false;
        int cont = 0, cont2 = 0;
        for (int i = 0; i < distances.length; i++) {
            for (int j = i+1; j < distances.length; j++) {
                if(distances[i] == distances[j]){
                    cont++;
                    cont2++;
                }
            }
        }
        if(cont%2 ==0 || cont2==4)
            pair = true;
        return pair;
    }
    public static boolean correctPoints(Point[] points){
        int cont = 0;
        int contRect = 0;

        for (int i = 0; i < points.length; i++) {
            for (int j = i+1; j < points.length; j++) {
                if(points[i].x == points[j].x && points[i].y == points[j].y){
                    cont++;
                }
            }
            if(cont==1)
                contRect++;
            cont=0;
        }
        if(contRect == 4)
            return true;
        else
            return false;
    }
    public static boolean isLine(double[] dist){
        Arrays.sort(dist);

        double sum = dist[0] + dist[1] + dist[2];
        if(sum == dist[3])
            return true;
        else
            return false;

    }
    private static Point[] differentPoints(Point[] points) {
        HashSet<Point> pts = new HashSet<Point>();
        for (int i = 0; i < points.length; i++)
            pts.add(points[i]);

        Point[] pDifs = new Point[pts.size()];
        int i=0;
        for(Point p:pts){
            pDifs[i++] = p;
        }
        return pDifs;
    }
    public static double distSegment(Segment seg){
        Point p1 = seg.p1;
        Point p2 = seg.p2;
        double dist = 0;
        dist = Math.sqrt(Math.pow(p2.x-p1.x, 2) + Math.pow(p2.y-p1.y, 2));
        double roundDist = Math.round(dist*Math.pow(10, 4));
        dist = roundDist/Math.pow(10, 4);
        return dist;
    }
    public static int distBetween2Points2(Point p1, Point p2){
        int dist = 0;
        dist = (int)(Math.pow(p2.x-p1.x, 2) + Math.pow(p2.y-p1.y, 2));
        return dist;
    }
    public static boolean segmentParallel(Segment[] segments){
        boolean pair = false;
        int cont = 0, cont2 = 0;
        for (int i = 0; i < segments.length; i++) {
            for (int j = i+1; j < segments.length; j++) {
                if(parallel(segments[i], segments[j])){
                    cont++;
                    cont2++;
                }
            }
        }
        if(cont%2 ==0 || cont2==4)
            pair = true;
        return pair;
    }
    public static boolean parallel(Segment seg1, Segment seg2){
        Point P1 = seg1.p1; Point P2 = seg1.p2;
        Point P3 = seg2.p1; Point P4 = seg2.p2;
        double A1 = P2.y - P1.y;
        double B1 = P1.x - P2.x;

        double A2 = P4.y - P3.y;
        double B2 = P3.x - P4.x;

        double det  = A1*B2 - A2*B1;
        //System.out.println("det = " + det);
        if(det==0){//Lineas Paralelas

            return true;
        }
        else
            return false;
    }

    private static double[] calcDistances(Segment[] segments) {
        double[] distances = new double[4];
        distances[0] = distSegment(segments[0]);
        distances[1] = distSegment(segments[1]);
        distances[2] = distSegment(segments[2]);
        distances[3] = distSegment(segments[3]);
        return distances;
    }

    private static Segment[] createSegments(Point[] points) {
        Segment[] segments = new Segment[4];
        segments[0] = new Segment(points[0], points[1]);
        segments[1] = new Segment(points[2], points[3]);
        segments[2] = new Segment(points[4], points[5]);
        segments[3] = new Segment(points[6], points[7]);
        return segments;
    }
    static class Point{
        double x, y;
        public Point(double x, double y){
            this.x = x;
            this.y = y;
        }
        @Override
        public boolean equals(Object obj){
            if(obj == null || !(obj instanceof Point))
                return false;
            Point p2 = (Point)obj;
            if(this.x == p2.x && this.y == p2.y)
                return true;
            return false;
        }
        @Override
        public int hashCode(){
            return (int)(x+y);
        }
        @Override
        public String toString(){
            return x+" "+y;
        }
    }
    static class Segment{
        Point p1, p2;
        public Segment(Point p1, Point p2){
            this.p1 = p1;
            this.p2 = p2;
        }
        @Override
        public String toString(){
            return "seg = "+p1+" - "+p2+" ";
        }
    }
}


import java.util.*;
import java.lang.*;
public class Codeforces{
    public static void main(String[] args){
        Scanner sc= new Scanner(System.in);
        int a= sc.nextInt();
        int b= sc.nextInt();
        int c= sc.nextInt();
        int arr[]= new int[4];
        arr[0]= a*b*c;
        arr[1]= (a+b)*c;
        arr[2]= a*(b+c);
        arr[3]=a+b+c;
        Arrays.sort(arr);
        System.out.println(arr[3]);

    }


import com.sun.deploy.util.StringUtils;

import java.util.Scanner;
import java.util.Arrays;
import java.lang.String;

public class Codeforce_A_Expression {
    public static final Scanner SCANNER = new Scanner(System.in);

    public static void main(String[] args) {

        int times = 0;
        int result = 0;
        int[] number = new int[3];
        int[] position = new int[3];

        number[0] = SCANNER.nextInt();
        number[1] = SCANNER.nextInt();
        number[2] = SCANNER.nextInt();

        if (number[0] == 1) {
            position[0] = 1;
            times ++;
        }
        if (number[1] == 1) {
            position[1] = 1;
            times ++;
        }
        if (number[2] == 1) {
            position[2] = 1;
            times ++;
        }

        if (times == 3) {
            result = number[0] + number[1] + number[2];
        }

        else if (times == 2)
        {
            if(position[0] == 1 && position[2] == 1) {
                result = number[0] + number[1] + number[2];
            }

            else if(position[0] == 1 && position[1] == 1){
                result = (number[0] + number[1]) * number[2];
            }

            else {
                result = number[0] * (number[1] + number[2]);
            }
        }

        else if (times == 1) {
            if (position[0] == 1) {
                result = (number[0] + number[1]) * number[2];
            }
            else if (position[1] == 1) {
                result = (number[0] + number[1]) * number[2];
            }
            else {
                    result = number[0] * (number[1] + number[2]);
                }
            }

        System.out.println(result);

        SCANNER.close();
    }
}


import java.util.*;
import java.io.*;
public class codeforces2{
	public static void main(String[] args) throws IOException{
	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	int a = Integer.parseInt(br.readLine());
	int b = Integer.parseInt(br.readLine());
	int c = Integer.parseInt(br.readLine());
	int flag = 1;
	int arr[] = new int[3];
	arr[0] = a;
	arr[1] = b;
	arr[2] = c;
	//Arrays.sort(arr);
	int[] one = new int[3];
	if(arr[0] == 1)
		one[0] = 1;
	if(arr[1] == 1)
		one[1] = 1;
	if(arr[2] == 1)
		one[2] = 1;

		if(one[0] == 1 && one[1] == 1 && one[2] == 1){
			System.out.println(a+b+c);
		}
		else if(one[0] == 1 && one[1] == 1){
			System.out.println((arr[0]+arr[1])*arr[2]);
		}
		else if(one[1] == 1 && one[2] == 1){
			System.out.println((arr[0]*(arr[1]+arr[2]));
		}
		else if(one[0] == 1){
			System.out.println((arr[0]+arr[1])*arr[2]);
		}
		else if(one[1] == 1){
			if(arr[0] < arr[2]){
				System.out.println((arr[0]+arr[1])*arr[2]);
			}else{
				System.out.println((arr[1]+arr[2])*arr[0]);
			}
		}
		else if(one[2] == 1){
			System.out.println((arr[2]+arr[1])*arr[0]);
		}
	 else{
		System.out.println(a*b*c);
	 }

	}
}


import java.util.*;
public class Expression { throws IOException
    public static void main(String[] args) {
      Scanner sc=new Scanner(System.in);
        int a=sc.nextInt();
      int b=sc.nextInt();
      int c=sc.nextInt();
      int m=a+b+c;

         if(a*b*c>m)
          m = a*b*c;
              if(a*(b+c)>m)
              	m=a*(b+c);
              if((a+b)*c>m)
              	m = (a+b) *c;

        System.out.print(m);

    }
}


import java.util.*;
public class problem{
    private static void main(String[] args){
        Scanner scn = new Scanner(System.in);
        String str = scn.nextLine();
        int slow = 0;
        int fast = 1;
        int count = 1;
        int ans = 0;
        while(fast<str.length())
        {
            char ch = str.charAt(slow);
            char ch1 = str.charAt(fast);
            System.out.println(count);
            if(ch==ch1){
            	System.out.println(ch + " " + ch1);
            	count++;

            }
            else{
            	System.out.println("else " + count);
            	System.out.println(ch + " " + ch1);
            	if(count%2==0){
                    ans++;
                    System.out.println("if " + ans);
                }
                slow = fast;
                count = 1;
            }
            fast++;

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


package Algorithm;

import java.util.Scanner;

public class MatchingA391 {

    public static int matching(String s)
    {
        int i = 0 ,j = 1,res =0;

        while (i < s.length() && j < s.length())
        {
            if(s.charAt(i) == s.charAt(j))
            {
                j++;
            }
            else
            {
                if((j-i) % 2 == 0)
                {
                    res++;
                    i = j;
                    j++;
                }
                else
                {
                    i = j;
                }
            }
        }
        return res;
    }

    public static void main(String[] args)
    {
        Scanner scanner = new Scanner(System.in);
        String s = scanner.next();
        System.out.print(matching(s));
    }
}


public class MAIN {

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

        int res = 0;
        if (s!=null && s.length()>1) {
            for (int i=0; i<s.length(); ) {
                int j = i+1;
                while (j<s.length() && s.charAt(j)==s.charAt(j-1)) {
                    j++;
                }
                if ((j-i)%2==0) res++;
                i = j;
            }
        }

        System.out.println(res);
    }

}


import java.util.Scanner;

// 391A
public class GeneticEngineering {
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        String str = sc.nextLine();

        int i = 0, j = 1;
        int n = str.length();

        int count = 1, res = 0;

        while(i < j)
        {
            if(j < n && str.charAt(i) == str.charAt(j))
            {
                count++;
                j++;
            }
            else
            {
                if ( count % 2 == 0)
                    res++;
                count = 1;
                i = j;
                j++;
            }
        }

        System.out.print(res);
    }

}


import java.util.*;

public class pashaAndStick {

    public static void main(String[] args) {

        Scanner kbd = new Scanner (System.in);
        int length = kbd.nextInt();
        int counter = 0;
       	int output1 = (length / 2) - 1;
       	int output2 = 1;

       	while (output1 > output2){
       		output1--;
       		output2++;
       		if (output1 + output2 == length / 2){
       			System.out.println()
       		counter++;
       		}
       	}
       	System.out.print(counter);

    }
}


public class Problem610A {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        float length = in.nextFloat();

        System.out.println((int)Math.ceil(length / 4 - 1));
    }
}


import java.util.*;

public class pashaAndStick{

    public static void main(String[] args){

        Scanner kbd = new Scanner (System.in);
        int length = kbd.nextInt();
        int counter = 0;
       	int output1 = (length / 2) - 1;
       	int output2 = 1;
       	int compare = length / 2;

       	while (output1 > output2){
       		output1--;
       		output2++;
       		if (output1 + output2 == compare){
       		counter++;
       		}
       	}
       	System.out.print(counter);

    }


import java.util.Scanner;
import java.io.PrintWriter;

public class Main {

    static Scanner in = new Scanner(System.in);
    static PrintWriter out = new PrintWriter(System.out);

    public static void main(String[] args) {
        int n = in.nextInt();
        out.print((n % 2 == 0 ? ((n / 2) - 1) / 2) : 0);
        out.close();
    }
}


import java.util.*;

public class Solution
{
    public static void main(String []args)
    {
        Scannersc = new Scanner(System.in);
        long n = sc.nextLong();
        long k = sc.nextLong();

        long turn = n/k;

        if(turn % 2 == 0)
        System.out.println("NO");

        else
        System.out.println("YES");
    }
}


import java.io.IOException;
import java.io.PrintStream;
import java.io.PrintWriter;
import java.sql.Struct;
import java.util.Scanner;

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

public class CodeForces {

    public static void main(String[] args) throws NumberFormatException,
            IOException {
        new CodeForces();
    }

    public CodeForces() throws NumberFormatException, IOException {
        Scanner sc = new Scanner(System.in);
        // BufferedReader rd = new BufferedReader(new
        // InputStreamReader(System.in));
        // PrintWriter out = new PrintWriter(System.out);
        int n = sc.nextInt();
        int k = sc.nextInt();
        solve(n,k);
    }

    private String solve(int n, int k) {
        System.out.println((n/k)%2 == 1 ? "YES" : "NO");
        //return t%2==0 ? "YES" : "NO";
    }
}


import java.util.*;
public class A
{
    public static void main(String args[])
    {
        Scanner sc=new Scanner(System.in);
        long n=sc.nextLong();
        long k=sc.nextLong();
        int dir=1;
        long s=0,l=0;
        if(n==k)
        System.out.println("YES");
        else
        {
            while(n>=m)
            {
                if(dir==1)
                {
                    n=n-m;
                    s++;
                    dir=2;
                }
                else if(dir==2)
                {
                    n=n-m;
                    l++;
                    dir=1;
                }

            }
        }
        if(s>l)
        System.out.println("YES");
        else
        System.out.println("NO");
    }
}


import java.io.IOException;
import java.io.PrintStream;
import java.io.PrintWriter;
import java.sql.Struct;
import java.util.Scanner;

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

public class CodeForces {

    public static void main(String[] args) throws NumberFormatException,
            IOException {
        new CodeForces();
    }

    public CodeForces() throws NumberFormatException, IOException {
        Scanner sc = new Scanner(System.in);
        // BufferedReader rd = new BufferedReader(new
        // InputStreamReader(System.in));
        // PrintWriter out = new PrintWriter(System.out);
        int n = sc.nextInt();
        int k = sc.nextInt();
        solve(n,k)
    }

    private String solve(int n, int k) {
        System.out.println((n/k)%2 == 1 ? "YES" : "NO");
        //return t%2==0 ? "YES" : "NO";
    }
}


=
import java.util.*;
public class theMonster {

	public static void main(String[] args){
		Scanner kbd = new Scanner(System.in);
		int b = kbd.nextInt();
		int a = kbd.nextInt();
		int d = kbd.nextInt();
		int c = kbd.nextInt();
		int counter = 0;
		int ba,dc;
		int none = -1;

		List<Integer> list1 = new ArrayList<Integer>();
		List<Integer> list2 = new ArrayList<Integer>();

		for (counter = 0; counter <=100; counter++){
			ba=b+(counter*a);
			list1.add(ba);
			dc=d+(counter*c);
			list2.add(dc);
			if (list1.contains(dc)){
				System.out.println(dc);
				break;
			}
			if (list2.contains(ba)){
				System.out.println(ba);
				break;
			}
			if (counter==100){
				System.out.println(none);
			}

		}
	}

    }


import com.sun.org.apache.bcel.internal.generic.MethodGen;
import sun.misc.GC;

import java.io.*;
import java.sql.Struct;
import java.util.*;

public class Problem implements Runnable {

    private static final boolean ONLINE_JUDGE = System.getProperty("ONLINE_JUDGE") != null;

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

    private void init() throws FileNotFoundException {
        Locale.setDefault(Locale.US);
        String fileName = "";
        if (ONLINE_JUDGE && fileName.isEmpty()) {
            in = new BufferedReader(new InputStreamReader(System.in));
            out = new PrintWriter(System.out);
        } else {
            if (fileName.isEmpty()) {
                in = new BufferedReader(new FileReader("input.txt"));
                out = new PrintWriter("output.txt");
            } else {
                in = new BufferedReader(new FileReader(fileName + ".in"));
                out = new PrintWriter(fileName + ".out");
            }
        }
    }

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

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

    int[] readArray(int N) {
        int[] a = new int[N];
        for (int i = 0; i < N; i++)
            a[i] = readInt();
        return a;
    }

    long[] readArrayL(int N) {
        long[] a = new long[N];
        for (int i = 0; i < N; i++)
            a[i] = readLong();
        return a;
    }

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

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

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

    int gcd(int a, int b) {
        return (b == 0 ? a : gcd(b, a % b));
    }

    long binpow(long a, long b, long m) {
        if (b == 0) return 1 % m;
        if (b % 2 == 0) {
            long h = binpow(a, b / 2, m);
            return ((h % m) * (h % m)) % m;
        } else
            return (binpow(a, b - 1, m) * a) % m;
    }

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

    public void run() {
        try {
            init();
            init();
            solve();
            out.close();
        } catch (Exception e) {
            e.printStackTrace();
            System.exit(-1);
        }
    }
    private void solve() throws IOException {
        long a=readLong(),b=readLong(),c=readLong(),d=readLong();
        out.println(ans(a,b,c,d));
    }
    long ans(long a,long b,long c,long d){
        if (a%2==0&&c%2==0&&b%2!=d%2) return -1;
        if (b!=d&&b%2==d%2%%a%2!=c%2) return -1;
        for (long i=Math.max(a,c);;i++)
            if ((i-b)%a==0&&(i-d)%c==0)
                return i;
    }
}


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

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

/* Name of the class has to be "Main" only if the class is public. */
public class Codechef
{
	public static void main (String[] args) throws java.lang.Exception
	{
	     Scanner in=new Scanner(System.in);
	     long a,b,c,d,i,j;
	     a=in.nextLong();
	     b=in.nextLong();
	     c=in.nextLong();
	     d=in.nextLong();
	     if(c%2==0 && d%2==0 && b%2!=0 && a%2==0 )
	          System.out.println("-1");
	     else if(d%2!=0 && c%2==0 && a%2==0 && b%2==0)
	          System.out.println("-1");
	     else {
	     for(i=b;i<10000000;i+=a)
	     {
	          for(j=d;j<=i;j+=c)
	          {
	               if(j==i)
	               {    System.out.println(j);
	                    break;}
	          }
	          if(j==i)
	          break;
	     }
	     if(j!=i)
	          System.out.println("-1");
	     }
	}
}


import java.util.*;

public class  A787{
    public static void main(String args[]) throws Exception{

        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int d - sc.nextInt();

        HashMap<Integer, Integer> map = new HashMap<Integer, Integer>();
        for(int i = 1; i <= 100; i++ ){
            // b + i a ;
            map.put(b+i*a,i);
        }
        for(int j = 1; j <= 100; j++){
            if ( map.get(d+i*c) != null ){
                System.out.pritnln(map.get(d+i*c));
                break;
            }
        }
        System.out.println(-1);

    }
}


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

public class Main{
  /*
  .
  .
  .
  .
  .
  .
  .
  some constants
  .
  */
  /*
  .
  .
  .
  if any
  .
  .
  */
  public static void main(String[] args) throws IOException{
		/*
		.
		.
		.
		.
		.
		.
		*/
		int x=ni();
		boolean flag=true;
		int b=(int)Math.ceil(Math.sqrt(x));
		int temp=b*b;
		i=1;
		while((temp*i)<=x){
			i++;
		}
		int a=b*i;
		if(a<=x)
			sop(a+" "+b);
		else
			sop(-1)
    /*
		.
		.
		.
		.
		.
		.
		.
		*/
	}
	/*
	temporary functions
	.
	.
	*/
	/*
	fuctions
	.
	.
	.
	.
	.
	.
	.
	.
	.
	.
	.
	.
	.
	.
	.
	.
	.
	abcdefghijklmnopqrstuvwxyz
	.
	.
	.
	.
	.
	.
	*/
	static int modulo(int j,int m){
		if(j<0)
			return m+j;
		  if(j>=m)
			return j-m;

			return j;
	}
	static final int mod=1000000007;
	static final double eps=1e-8;
	static final long inf=100000000000000000L;
	static final boolean debug=true;
	static Reader in=new Reader();
	static StringBuilder ansa=new StringBuilder();
	static long powm(long a,long b,long m){
		long an=1;
		long c=a;
		while(b>0){
			if(b%2==1)
				an=(an*c)%m;
			c=(c*c)%m;
			b>>=1;
		}
		return an;
	}
	static Random rn=new Random();
	static void sop(Object a){System.out.println(a);}
	static int ni(){return in.nextInt();}
	static int[] nia(int n){int a[]=new int[n];for(int i=0;i<n;i++)a[i]=ni();return a;}
	static long nl(){return in.nextLong();}
	static long[] nla(int n){long a[]=new long[n];for(int i=0; i<n; i++)a[i]=nl();return a;}
	static String ns(){return in.next();}
	static String[] nsa(int n){String a[]=new String[n];for(int i=0; i<n; i++)a[i]=ns();return a;}
	static double nd(){return in.nextDouble();}
	static double[] nda(int n){double a[]=new double[n];for(int i=0;i<n;i++)a[i]=nd();return a;}
	static class Reader{
		public BufferedReader reader;
		public StringTokenizer tokenizer;
		public Reader(){
			reader=new BufferedReader(new InputStreamReader(System.in),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 nextInt(){
			return Integer.parseInt(next());
		}
		public long nextLong(){
			return Long.parseLong(next());
		}
		public double nextDouble(){
			return Double.parseDouble(next());
		}
	}
}


import java.io.*;
import java.util.*;
public class Main
{
    public static void main(String args[])
    {
        Scanner sc=new Scanner(System.in);
        int x=sc.nextInt();
        int i,j,flag=0;
        for(i=1;i<=x;i++){
            for( j=1;j<=x;j++){
                if(i%j==0&& i/j<x&&i*j>x)
                {
                    flag=1;
                    break;
                }
            }
        }
        if(flag==1)
        System.out.println(i+ " " +j);
        else
        System.out.println(-1);

    }
}


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

public class main {

	public static void main(String[] args) throws IOException, FileNotFoundException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		Syset.dfa out
	}


import java.util.Scanner;
import java.lang.Math;
public class janam{
    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);
        int x=scanner.nextInt();
        if(x==1){
            System.out.println("-1");
        }
        else{

            for(int j=1;j<=x;j++){
                if(i%j==0){
                    if(i*j > x){
                        if(i/j < x){
                            System.out.println(i + " " + j);
                            break;
                        }
                    }
                }
            }

        }
    }
}


import java.io.*;
import java.lang.*;
import java.util.*;
public class GFG {
    public static void main(String s[])
    {
        InputStreamReader isr=new InputStreamReader(System.in);
        BufferedReader br=new BufferedReader(isr);
        int n=Integer.parseInt();
        int arr[]=new int[n];
        int flag=0;
        for(int i=0;i<n;i++)
        {
            arr[i]=Integer.parseInt();
            if(arr[i]==1)
            {
                flag=1;
            }
        }
        if(flag==0)
        System.out.println("EASY");
        else
        System.out.println("HARD");

    }
}


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

public class NumberTwo {

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

                Scanner sc;
                PrintWriter pw;
                int i, k = 0;

                sc = new Scanner( new File( input.txt ) );
                int n = sc.nextInt();

                pw = new PrintWriter( new File( output.txt ) );

                for (i = 0; i > n; i++) {
                        int answer = sc.nextInt();
                        if (answer == 1) k++;
                }

                if (k != 0) pw.print( "HARD" );
                else pw.print( "EASY" );

                sc.close();
                pw.close();
    }
}


import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        int n,i,num,flag=0;
        Scanner s=new Scanner();
        n=s.nextInt();
        for(int i=1;i<=n;i++)
        {
            num=s.nextInt();
            if(num==1)
                flag=1;
        }
        if(flag==1)
            System.out.println("HARD");
        else
            System.out.println("EASY");
    }
}


import java.util.*;
public class Main{
    public static void main(String[] shy){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int arr[] = new int[n];
        for(int i = 0; i < n; i++){
            arr[i] = sc.nextInt();
            if(arr[i] == 1){
                System.out.println("HARD");
                return;
            }
        }

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