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

public class Solution {

    static void calc(double[] a, double x, double y, double z) {
        if (x == 1)
            a[0] = a[1] = a[2] = a[3] = 1;
        else if (x > 1) {
            a[0] = z * Math.log(y) + Math.log(Math.log(x));
            a[1] = y * Math.log(z) + Math.log(Math.log(x));
            a[2] = Math.log(z * y * Math.log(x));
            a[3] = a[2];
        }

        if (y == 1)
            a[4] = a[5] = a[6] = a[7] = 1;
        else if (y > 1) {
            a[4] = z * Math.log(x) + Math.log(Math.log(y));
            a[5] = x * Math.log(z) + Math.log(Math.log(y));
            a[6] = Math.log(z * x * Math.log(y));
            a[7] = a[6];
        }

        if (z == 1)
            a[8] = a[9] = a[10] = a[11] = 1;
        else if (z > 1) {
            a[8] = y * Math.log(x) + Math.log(Math.log(z));
            a[9] = x * Math.log(y) + Math.log(Math.log(z));
            a[10] = Math.log(y * x * Math.log(z));
            a[11] = a[10];
        }
    }

    static void solve(InputReader in, OutputWriter out) {
        double x = in.nextDouble();
        double y = in.nextDouble();
        double z = in.nextDouble();

        String[] ans = {"x^y^z", "x^z^y", "(x^y)^z", "(x^z)^y", "y^x^z", "y^z^x", "(y^x)^z", "(y^z)^x", "z^x^y", "z^y^x", "(z^x)^y", "(z^y)^x"};
        double[] a = new double[12];
        if (x <= 1 && y <= 1 && z <= 1) {
            calc(a, 1 / x, 1 / y, 1 / z);

            double min = Double.MAX_VALUE;
            int index = -1;
            for (int i = 0; i < a.length; i++)
                if (a[i] < min) {
                    min = a[i];
                    index = i;
                }
            out.print(ans[index]);

        } else {
            calc(a, x, y, z);

            double max = Double.MIN_VALUE;
            int index = -1;
            for (int i = 0; i < a.length; i++)
                if (a[i] > max) {
                    max = a[i];
                    index = i;
                }
            out.print(ans[index]);
        }
    }

    public static void main(String[] args) {
        InputReader in = new InputReader(System.in);
        OutputWriter out = new OutputWriter(System.out);
        solve(in, out);
        in.close();
        out.close();
    }

    static class InputReader {
        BufferedReader br;
        StringTokenizer st;

        InputReader(InputStream is) {
            br = new BufferedReader(new InputStreamReader(is));
            st = null;
        }

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

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

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

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

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

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

    static class OutputWriter {
        BufferedWriter bw;

        OutputWriter(OutputStream os) {
            bw = new BufferedWriter(new OutputStreamWriter(os));
        }

        void print(int i) {
            print(Integer.toString(i));
        }

        void println(int i) {
            println(Integer.toString(i));
        }

        void print(long l) {
            print(Long.toString(l));
        }

        void println(long l) {
            println(Long.toString(l));
        }

        void print(double d) {
            print(Double.toString(d));
        }

        void println(double d) {
            println(Double.toString(d));
        }

        void print(boolean b) {
            print(Boolean.toString(b));
        }

        void println(boolean b) {
            println(Boolean.toString(b));
        }

        void print(char c) {
            try {
                bw.write(c);
            } catch (IOException e) {
                e.printStackTrace();
            }
        }

        void println(char c) {
            println(Character.toString(c));
        }

        void print(String s) {
            try {
                bw.write(s);
            } catch (IOException e) {
                e.printStackTrace();
            }
        }

        void println(String s) {
            print(s);
            print('\n');
        }

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


import java.util.ArrayDeque;
import java.util.Queue;
import java.util.Scanner;

/**
 *
 * @author 20130898
 */
public class BeautifulMatrix {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args)
    {
        Scanner scanner = new Scanner(System.in) ;
        Queue<bfs> q = new ArrayDeque<bfs>() ;

        int[][] matrix = new int[5][5] ;
        int ro = 0 ;
        int co = 0 ;
        int cost = 0 ;

        for (int i = 0; i < 5; i++)
        {
            for (int j = 0; j < 5; j++)
            {
                matrix [i][j] = scanner.nextInt() ;

                if(matrix[i][j] == 1)
                {
                    ro = i ;
                    co = j ;
                }

            }
        }
         q.offer(new bfs(ro,co,0));
        while(!q.isEmpty())
        {
            bfs degt  = q.poll() ;
            if(degt.col == 2 && degt.row == 2)
            {
                System.out.println(degt.count);
            }

            int [] rows = new int[] {0 , 0  , -1 , 1} ;
            int [] colm = new int[] {-1 , 1 , 0 , 0 } ;

            for (int i = 0; i < 4; i++)
            {
                int rr = rows[i] ;
                int cc = colm [i] ;

                if(-1 < rr && rr<5 && -1 < cc && cc < 5)
                {
                    q.offer(new bfs(rr,cc,degt.count+1));
                }

            }
        }

    }

    private static class bfs
    {
        int row ;
        int col ;
         int count;

         public bfs(int row, int col, int count) {
            this.row = row;
            this.col = col;
            this.count = count;
        }
    }
}


import java.util.Scanner;
public class Main4_1
{
  public static void main(String []args)
  {
    Scanner sc=new Scanner(System.in);
    int ndi=sc.nextInt();
    int i=0;
    int x=0;
    while(i<=ndi)
    {
      x=x++;
      int y=x;
      for(int j=0;y>0;j++)
      {
        y=y/10;
        i=i++;
      }
    }
    while(i!=ndi)
    {
      x=x/10;
      i=i--;
    }
    System.out.println(x);
  }
}


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

public class P14C {

  int xyi = -1;
  int [] x = new int [4];
  int [] y = new int [4];
  int [] c = new int [4];

  boolean putXY(int xx, int yy) {
    int i = 0;
    for (; i <= xyi; i++) {
      if (xx == x[i] && yy == y[i]) {
        break;
      }
    }

    if (i <= xyi) {
      if (c[i] == 2) {
        return false;
      }
      c[i]++;
    } else {
      if (xyi == 3) {
        return false;
      }
      xyi++;
      x[xyi] = xx;
      y[xyi] = yy;
      c[xyi] = 1;
    }

    return true;
  }

  public void run() throws Exception {
    for (int i = 0; i < 8; i++) {
      if (!putXY(nextInt(), nextInt())) {
        println("NO");
        return;
      }
    }

    int h = 0;
    int v = 0;
    for (int i = 0; i < 3; i++) {
      for (int j = i + 1; j < 4; j++) {
        if ((x[i] - x[j] == 0) && (y[i] - y[j] != 0)) {
          v++;
        } else if ((x[i] - x[j] != 0) && (y[i] - y[j] == 0)) {
          h++;
        }
      }
    }

    println((h == 2 && v == 2) ? "YES" : "NO");
  }

  public static void main(String... args) throws Exception {
    br = new BufferedReader(new InputStreamReader(System.in));
    pw = new PrintWriter(new BufferedOutputStream(System.out));
    new P14C().run();
    br.close();
    pw.close();
  }

  static BufferedReader br;
  static PrintWriter pw;
  StringTokenizer stok;

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

  void print(byte b) {
    print("" + b);
  }

  void print(int i) {
    print("" + i);
  }

  void print(long l) {
    print("" + l);
  }

  void print(double d) {
    print("" + d);
  }

  void print(char c) {
    print("" + c);
  }

  void print(StringBuffer sb) {
    print("" + sb);
  }

  void print(String s) {
    pw.print(s);
  }

  void println(byte b) {
    println("" + b);
  }

  void println(int i) {
    println("" + i);
  }

  void println(long l) {
    println("" + l);
  }

  void println(double d) {
    println("" + d);
  }

  void println(char c) {
    println("" + c);
  }

  void println(StringBuffer sb) {
    println("" + sb);
  }

  void println(String s) {
    pw.println(s);
  }

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

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

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

  char nextChar() throws IOException {
    return (char) (br.read());
  }

  String next() throws IOException {
    return nextToken();
  }

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

}


import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.BitSet;
import java.util.Calendar;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.PriorityQueue;
import java.util.SortedSet;
import java.util.Stack;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;

/**
 * #
 * @author pttrung
 */
public class B_Round_213_Div1 {

    public static long MOD = 1000000007;

    public static void main(String[] args) throws FileNotFoundException {
        // PrintWriter out = new PrintWriter(new FileOutputStream(new File(
        // "output.txt")));
        PrintWriter out = new PrintWriter(System.out);
        Scanner in = new Scanner();
        int n = in.nextInt();
        int d = in.nextInt();
        int[] data = new int[n];
        for (int i = 0; i < n; i++) {
            data[i] = in.nextInt();
        }
        Arrays.sort(data);
        int max = 0;
        for (int i = 0; i < n; i++) {
            if (max + d >= data[i]) {
                max += data[i];
            }
        }
        int v = cal(max, 0, d, new boolean[n], data);
        out.println(max + " " + v);
        out.close();
    }

    public static int cal(int max, int have, int d, boolean[] taken, int[] data) {
        if (max == have) {
            return 0;
        }
        int left = max - have;
        int[] a = new int[max + 1];
        int[] b = new int[max + 1];
        Arrays.fill(a, -1);
        Arrays.fill(b, -1);
        TreeSet<Integer> set = new TreeSet();
        TreeSet<Integer> o = new TreeSet();
        set.add(0);
        o.add(0);
        for (int i = 0; i < data.length; i++) {
            if (taken[i]) {
                for (int j : set) {
                    if ( j + data[i] <= max && a[j + data[i]] == -1) {
                        a[j + data[i]] = i;
                        set.add(j + data[i]);
                    }
                }
            } else {
                for (int j : o) {
                    if (j + data[i] <= max && b[j + data[i]] == -1) {
                        b[j + data[i]] = i;
                        o.add(j + data[i]);
                    }
                }
            }
        }
        //System.out.println(Arrays.toString(b) + " " + set);
        int cur = 0;
        int result = -1;
        int other = 0;
        for (int i = max; i >= 0; i--) {
            if (b[i] != -1) {
                Integer v = set.ceiling(i - d);

                if (v != null) {

                    int tmp = have - v + i;
                    if (tmp > cur) {
                        cur = tmp;
                        other = v;
                        result = i;
                    }
                }
            }
        }
       // System.out.println(cur + " " + other + " " + result + " " + d);
        while (result > 0) {
            taken[b[result]] = true;
            result -= data[b[result]];
           // System.out.println(result);
        }
        while (other > 0) {
            taken[a[other]] = false;
            other -= data[a[other]];

        }

        return 1 + cal(max, cur, d, taken, data);

    }

    public static int[] KMP(String val) {
        int i = 0;
        int j = -1;
        int[] result = new int[val.length() + 1];
        result[0] = -1;
        while (i < val.length()) {
            while (j >= 0 && val.charAt(j) != val.charAt(i)) {
                j = result[j];
            }
            j++;
            i++;
            result[i] = j;
        }
        return result;

    }

    public static boolean nextPer(int[] data) {
        int i = data.length - 1;
        while (i > 0 && data[i] < data[i - 1]) {
            i--;
        }
        if (i == 0) {
            return false;
        }
        int j = data.length - 1;
        while (data[j] < data[i - 1]) {
            j--;
        }
        int temp = data[i - 1];
        data[i - 1] = data[j];
        data[j] = temp;
        Arrays.sort(data, i, data.length);
        return true;
    }

    public static int digit(long n) {
        int result = 0;
        while (n > 0) {
            n /= 10;
            result++;
        }
        return result;
    }

    public static double dist(long a, long b, long x, long y) {
        double val = (b - a) * (b - a) + (x - y) * (x - y);
        val = Math.sqrt(val);
        double other = x * x + a * a;
        other = Math.sqrt(other);
        return val + other;

    }

    public static class Point implements Comparable<Point> {

        int x, y;

        public Point(int start, int end) {
            this.x = start;
            this.y = end;
        }

        @Override
        public int hashCode() {
            int hash = 5;
            hash = 47 * hash + this.x;
            hash = 47 * hash + this.y;
            return hash;
        }

        @Override
        public boolean equals(Object obj) {
            if (obj == null) {
                return false;
            }
            if (getClass() != obj.getClass()) {
                return false;
            }
            final Point other = (Point) obj;
            if (this.x != other.x) {
                return false;
            }
            if (this.y != other.y) {
                return false;
            }
            return true;
        }

        @Override
        public int compareTo(Point o) {
            return x - o.x;
        }
    }

    public static class FT {

        long[] data;

        FT(int n) {
            data = new long[n];
        }

        public void update(int index, long value) {
            while (index < data.length) {
                data[index] += value;
                index += (index & (-index));
            }
        }

        public long get(int index) {
            long result = 0;
            while (index > 0) {
                result += data[index];
                index -= (index & (-index));
            }
            return result;

        }
    }

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

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

        }
    }

    static class Scanner {

        BufferedReader br;
        StringTokenizer st;

        public Scanner() throws FileNotFoundException {
            // System.setOut(new PrintStream(new BufferedOutputStream(System.out), true));
            br = new BufferedReader(new InputStreamReader(System.in));
            //  br = new BufferedReader(new InputStreamReader(new FileInputStream(new File("input.txt"))));
        }

        public String next() {

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

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

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

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

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

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


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

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

    static class CWhiteSheet {
        public void solve(int testNumber, InputReader in, OutputWriter out) {
            Point[] white = new Point[2];
            for (int i = 0; i < 2; i++) {
                white[i] = new Point(in.i(), in.i());
            }
            Point[] fb = new Point[2];
            for (int i = 0; i < 2; i++) {
                fb[i] = new Point(in.i(), in.i());
            }
            Point[] fs = new Point[2];
            for (int i = 0; i < 2; i++) {
                fs[i] = new Point(in.i(), in.i());
            }
            Point[] whiteB = GeoUtil.findIntersectionPointsOfRectangle(white[0], white[1], fb[0], fb[1]);
            Point[] whiteS = GeoUtil.findIntersectionPointsOfRectangle(white[0], white[1], fs[0], fs[1]);
            if (whiteB[0].x > whiteS[0].x) {
                Point[] temp = whiteB;
                whiteB = whiteS;
                whiteS = temp;
            } else if (whiteB[0].x == whiteS[0].x) {
                if (whiteB[0].y < whiteS[0].y) {
                    Point[] temp = whiteB;
                    whiteB = whiteS;
                    whiteS = temp;
                }
            }
//        if (find(white, whiteB, whiteS)) {
//            out.printLine("NO");
//            return;
//        }
            long areaW = (long) (Math.abs(white[1].x - white[0].x)) * (long) (Math.abs(white[1].y - white[0].y));
            long areaF = (long) (long) (Math.abs(whiteB[1].x - whiteB[0].x)) * (long) (Math.abs(whiteB[1].y - whiteB[0].y));
            long areaS = (long) (Math.abs(whiteS[1].x - whiteS[0].x)) * (long) (Math.abs(whiteS[1].y - whiteS[0].y));
            if (areaF + areaS >= areaW) {
                out.printLine("NO");
            } else {
                out.printLine("YES");
            }
        }

    }

    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 print(Object... objects) {
            for (int i = 0; i < objects.length; i++) {
                if (i != 0) {
                    writer.print(' ');
                }
                writer.print(objects[i]);
            }
        }

        public void printLine(Object... objects) {
            print(objects);
            writer.println();
        }

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

    }

    static class GeoUtil {
        public static Point[] findIntersectionPointsOfRectangle(Point l1, Point r1, Point l2, Point r2) {
            Point leftBottom = new Point(Math.max(l1.x, l2.x), Math.max(l1.y, l2.y));
            Point topUp = new Point(Math.min(r1.x, r2.x), Math.min(r1.y, r2.y));
            return new Point[]{leftBottom, topUp};
        }

    }

    static class InputReader {
        private InputStream is;
        private byte[] inbuf = new byte[1024];
        private int lenbuf = 0;
        private int ptrbuf = 0;

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

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

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

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

    }

    static class Point {
        public long x;
        public long y;

        public Point(int x, int y) {
            this.x = x;
            this.y = y;
        }

        public Point(long x, long y) {
            this.x = x;
            this.y = y;
        }

        public boolean equals(Object o) {
            if (this == o) return true;
            if (o == null || getClass() != o.getClass()) return false;
            Point point = (Point) o;
            return x == point.x &&
                    y == point.y;
        }

        public int hashCode() {
            return Objects.hash(x, y);
        }

    }
}


import java.util.*;

public class Test {
	public static void main(String[] args) {
	    Scanner in = new Scanner(System.in);
	    String input = in.nextLine();
		String[] strs = input.trim().split(" ");
		int[] ins = new int[strs.length];

		for (int i = 0; i < strs.length; i++) {
			ins[i] = Integer.parseInt(strs[i]);
		}

		int[] wave = new int[ins[0] + ins[1] + 1];

		if(((ins[1] <= ins[0]) && (ins[1] >= 1)) && ((ins[2] <= ins[0] + ins[1]) && (ins[2] >= 1))){
			for(int a = 0; a < wave.length; a++) {
				if(a < ins[1]) {
					wave[a] = a;
				}
				else if((a >= ins[1]) && (a <= ins[0])) {
					wave[a] = ins[1];
				}
				else {
					wave[a] = wave[(ins[0] + ins[1]) - a];
				}
			}
		}
		else {
			System.exit(0);
		}

			System.out.print(wave[ins[2]]);
	}
}


//package round85;import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;

public class D {
	Scanner in;
	PrintWriter out;
	String INPUT = "";
	int mod = 1000000007;

	// 1列の場合はなんでもありなのでk^n
	// 2列の場合はどっちも同じi色であればいいので、
	// \sum_i (C(k,i)F(n,i))^2
	// 3列以上の場合は全部同じ配色。
	// \sum_i (C(k,i)F(n,i))^m
	// F(n,i)はn行をちょうどi色で塗る塗り方
	// F(n,i)=i^n-C(i,1)(i-1)^n+C(i,2)(i-2)^n-...
	// これを求めるのにO(i)
	// 全体でO(k^2)かかってしまうので普通の計算では間に合わない。
	//
	//

	void solve()
	{
		int n = ni();
		int m = ni();
		int K = ni();

		long[][] C = new long[1001][1001];
		for(int i = 0;i <= 1000;i++){
			C[i][0] = 1;
			for(int j = 1;j <= i;j++){
				C[i][j] = (C[i-1][j] + C[i-1][j-1])% mod;
			}
		}
		long[] I = new long[1001];
		for(int i = 0;i <= 1000;i++){
			I[i] = modpow(i, n, mod);
		}

		// F(n,i)=i^n-C(i,1)(i-1)^n+C(i,2)(i-2)^n-...
		long[] F = new long[1001];
		for(int i = 0;i <= 1000;i++){
			long val = 0;
			long minus = 1;
			for(int j = i;j >= 0;j--){
				val += modpow(j, n, mod) * minus * C[i][j] % mod;
				minus = -minus;
			}
			F[i] = val % mod;
		}

		if(m == 1){
			out.println(modpow(K, n, mod));
		}else if(m == 2){
			long sum = 0;
			long c = 1;
			for(int i = 1;i <= K;i++){
				c = c * (K-i+1) % mod;
				c = c * inv(i, mod) % mod;
				long cfm = c*F[i]%mod;
				sum += cfm*cfm%mod;
			}
			out.println(sum%mod);
		}else{
			long sum = 0;
			long c = 1;
			for(int i = 1;i <= K;i++){
				c = c * (K-i+1) % mod;
				c = c * inv(i, mod) % mod;
				c = mod - c;
				long all = c*modpow(F[i], m, mod)%mod;
				sum += all;
			}
			out.println(sum%mod);
		}
	}

	public static long inv(long a, int p)
	{
		long ret = 1;
		long mul = a;
		for(long n = p-2;n > 0;n >>>= 1){
			if((n&1)==1)ret = ret * mul % p;
			mul = mul * mul % p;
		}
		return ret;
	}

	public static long modpow(long a, long n, long mod)
	{
		long ret = 1;
		long mul = a;
		for(;n > 0;n >>>= 1){
			if((n&1)==1){
				ret = (ret * mul) % mod;
			}
			mul = (mul * mul) % mod;
		}
		return ret;
	}

	void run() throws Exception
	{
		in = oj ? new Scanner(System.in) : new Scanner(INPUT);
		out = new PrintWriter(System.out);

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

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

	int ni() { return Integer.parseInt(in.next()); }
	long nl() { return Long.parseLong(in.next()); }
	double nd() { return Double.parseDouble(in.next()); }
	boolean oj = System.getProperty("ONLINE_JUDGE") != null;
	void tr(Object... o) { if(!oj)System.out.println(Arrays.deepToString(o)); }
}


import java.util.Scanner;

public class CodeForces
{
	public static void main( String args[] )
	{
		Scanner input = new Scanner( System.in );
		int d = input.nextInt();
		int k = input.nextInt();
		int a = input.nextInt();
		int b = input.nextInt();
		int t = input.nextInt();
		int time = k * a;;
		int car, foot;

		car = a * k + t;
		foot = b * k;

		if( car <= foot )
			time += (d - k)/k * car;
		else
			time += (d - k)/k * foot;

		car = a * (d%k) + t;
		foot = b * (d%k);

		if( car <= foot )
			time += car;
		else
			time += foot;

		System.out.println(time);
	}
}


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

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

    static class AComparingStrings {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            String a = in.readString();
            String b = in.readString();

            if (a.length() != b.length()) {
                System.out.println("NO");
                return;
            } else {
                char[] c = a.toCharArray();

                for (int i = 0; i < c.length; i++) {
                    for (int j = 0; j < c.length; j++) {
                        if (i == j)
                            continue;
                        //swap
                        char tmp = c[i];
                        c[i] = c[j];
                        c[j] = tmp;

//                    if (i == 0 && j == 3) {
//                        System.out.println(Arrays.toString(c));
//                        System.out.println(b);
//                    }
                        if (new String(c).equals(b)) {
                            System.out.println("YES");
                            return;
                        }

                        tmp = c[j];
                        c[j] = c[i];
                        c[i] = tmp;
                    }
                }

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

    }

    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 RuntimeException();
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new RuntimeException();
                }
                if (numChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }

        public String readString() {
            final StringBuilder stringBuilder = new StringBuilder();
            int c = read();
            while (isSpaceChar(c))
                c = read();
            do {
                stringBuilder.append((char) c);
                c = read();
            } while (!isSpaceChar(c));
            return stringBuilder.toString();
        }

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

    }
}


public class InfiniteSequence {

	public static void main(String... args) {

		Scanner sc = new Scanner(System.in);
		long num = sc.nextLong();
		sc.close();
		System.out.println(solve(num));

	}

	public static long solve(long n) {

		long i = 1;
		while (n > i) {
			n = n - i++;
		}

		return n;

	}


import java.util.Scanner;

/**
 * Created by makarfi on 12/17/17.
 */
public class B {
    static int[] months = new int[]{31, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30};// dec - nov
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);

        int n = in.nextInt();
        int[] a = new int[n];
        for (int i = 0; i < a.length; i++) a[i] = in.nextInt();

        boolean leapYear = false, done = false;
        for (int start = 0; start < months.length; start++) {
            int pos = 0;
            for (int i = start; pos < n; i = (i+1)%12) {
                if (i == 2) {
                    if (a[pos] == 29 && !leapYear) {
                        leapYear = true;
                        pos++;
                    } else if (a[pos] == 29 && leapYear) {
                        break;
                    } else {
                        pos++;
                    }
                } else if (months[i] == a[pos]) {
                    pos++;
                } else {
                    break;
                }
            }
            if (pos == n) done = true;

        }

        System.out.println(done ? "YES" : "NO");
    }
}


import java.util.Scanner;

public class ToyArmy {

    public static void main(String[] args) {
        Scanner inScanner = new Scanner(System.in);
        int n = inScanner.nextInt();
        int max = 0;
        for (int i = 0; i <= n; i++)
            for (int j = 0; j <= n - i; j++)
                if (i + j + Math.min(n - i, n - j) > max)
                    max = i + j + Math.min(n - i, n - j);
        System.out.println(max);
    }
}


import java.util.*;

public class Test {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long x = sc.nextLong();
		long y = sc.nextLong();
		int n = sc.nextInt();
		long mod = 1000000007;
		long[] arr = new long[n];
		arr[0] = (x + mod) % mod;
		arr[1] = (y + mod) % mod;
		for(int i = 2; i < n; ++i) {
			arr[i] = (arr[i - 1] - arr[i - 2] + mod) % mod;
		}
		System.out.println(arr[n - 1]);
		sc.close();
	}

}


import java.util.Scanner;
public class Test45{
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        in n= input.nextInt();
        int inches=(n+1)/3;
        int feet=inches/12;
        System.out.println(feet+" "+(inches-12*feet));
    }
}


import java.util.Scanner;

public class LuckyNumberEasy {
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		@SuppressWarnings("resource")
		Scanner scn = new Scanner(System.in);
		String s = scn.next();

		if(Integer.parseInt(s) > 99999998) {
			System.out.println("4444477777");
		}
		else if(Integer.parseInt(s) > 777445 && Integer.parseInt(s) < 44447776) {
			System.out.println("44447777");
		}
		else {
		boolean check = checkSuperLucky(s);
		if (check == true
				&& (long) s.chars().filter(ch -> ch == '4').count() == (long) s.chars().filter(ch -> ch == '7').count()) {
			System.out.println(s);
		} else {
			long temp = Integer.parseInt(s);
			for (long i = temp + 1; i < 1000000000; i++) {
				String temp1 = String.valueOf(i);
				if (checkSuperLucky(temp1) && (long) temp1.chars().filter(ch -> ch == '4').count() == (long) temp1.chars()
						.filter(ch -> ch == '7').count()) {
					System.out.println(temp1);
					break;
				}
			}
		}
	}
}

	public static boolean checkSuperLucky(String s) {
		boolean check = true;

		for (int i = 0; i < s.length(); i++) {
			String ch = String.valueOf(s.charAt(i));
			if (!ch.contains("0") && !ch.contains("1") && !ch.contains("2") && !ch.contains("3") && ch.contains("4")
					&& !ch.contains("5") && !ch.contains("6") && !ch.contains("8") && !ch.contains("9")
					|| !ch.contains("0") && !ch.contains("1") && !ch.contains("2") && !ch.contains("3")
							&& !ch.contains("5") && !ch.contains("6") && ch.contains("7") && !ch.contains("8")
							&& !ch.contains("9")) {
			} else {
				check = false;
				break;
			}
		}
		return check;
	}
}


import java.io.*;
import java.util.*;
//import java.math.BigInteger;
public class Solution {

    public static void main(String[] args) {
        Scanner snr=new Scanner(System.in);
        long n=snr.nextLong();
        long ans=0;
        if (n%2 == 0) a = n/2;
		else a = (-1)*(n/2 + 1);
        System.out.println(a);
        /* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */
    }
}


import java.util.Scanner;

public class LuckyDays {

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

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

        int l1 = in.nextInt();
        int r1 = in.nextInt();
        int t1 = in.nextInt();
        int l2 = in.nextInt();
        int r2 = in.nextInt();
        int t2 = in.nextInt();

        int a = r1 - l1 + 1;
        int b = r2 - l2 + 1;
        int gcd = gcd(t1, t2);
        int dl = l2 - l1;

        if (dl % gcd == 0) {
            System.out.println(Math.min(a, b));
        } else {
            int ans = 0;
            ans = Math.max(ans, Math.min(a - dl % gcd, b));
            ans = Math.max(ans, Math.min(a, b - (gcd - dl % gcd)));
            System.out.println(ans);
        }
    }
}


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

/**
 * Created by Firеfly on 1/1/2017.
 */
public class C_Forcess {
    public static void main(String[] args) throws IOException {
        Emaxx emaxx = new Emaxx();
    }
}

class Emaxx {
    FScanner fs;
    PrintWriter pw;
    Emaxx() throws IOException {
        fs = new FScanner(new InputStreamReader(System.in));
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
   //     pw = new PrintWriter(new FileWriter("output.txt"));
    //    fs = new FScanner(new FileReader("input.txt"));
        pw = new PrintWriter(System.out);
        char[][] mas = new char[4][4];
        mas[0] = fs.nextLine().toCharArray();
        mas[1] = fs.nextLine().toCharArray();
        mas[2] = fs.nextLine().toCharArray();
        mas[3] = fs.nextLine().toCharArray();
        boolean can = false;
        for (int i = 0; i<4; i++) {
            for (int j = 0; j<4; j++) {
                if (j<2 && mas[i][j] == 'x') {
                    if (mas[i][j+1] == 'x') {
                        if (mas[i][j+2] == '.')
                            can = true;
                    }
                    else if (mas[i][j+1] == '.')
                        if (mas[i][j+2] == 'x')
                            can = true;
                }
                if (j == 2) {
                    if (((mas[i][j+1] == 'x' && mas[i][j-1] == '.') || (mas[i][j-1] == 'x' && mas[i][j+1] =='.')) && mas[i][j] =='x')
                    can = true;
                }
                if (i == 2) {

                    if (((mas[i+1][j] == 'x' && mas[i-1][j-1] == '.') || (mas[i-1][j] == 'x' && mas[i+1][j] =='.')) && mas[i][j] =='x')
                        can = true;
                }
                if (i == 2 && j == 1) {
                    if (mas[i][j] == 'x' && ((mas[i+1][j-1] =='x' && mas[i-1][j+1] =='.') || (mas[i+1][j-1] =='.' && mas[i-1][j+1] == 'x')))
                        can = true;
                }
                if (i == 2 && j == 2) {

                    if (mas[i][j] == 'x' && ((mas[i+1][j+1] =='x' && mas[i-1][j-1] =='.') || (mas[i+1][j+1] =='.' && mas[i-1][j-1] == 'x')))
                        can = true;
                }
                if (i<2 && mas[i][j] == 'x') {
                    if (mas[i+1][j] == 'x') {
                        if (mas[i + 2][j] == '.')
                            can = true;
                    } else if (mas[i+1][j] == '.')
                    {
                        if (mas[i+2][j] =='x')
                            can = true;
                    }
                }
                if (((i==j && i<2) || (i == 0 && j == 1) || (i == 1 && j == 0)) && mas[i][j] == 'x') {
                    if (mas[i+1][j+1] == 'x') {
                        if (mas[i+2][j+2] == '.')
                            can = true;
                    } else if (mas[i+1][j+1] == '.') {
                        if (mas[i+2][j+2] =='x')
                            can = true;
                    }
                }
                if (((i == 0 && j == 3) || (i == 1 && j == 2) || (i==0 && j==2) || (i==1 && j==3 )) && mas[i][j] == 'x') {
                    if (mas[i+1][j-1] == 'x') {
                        if (mas[i+2][j-2] == '.')
                            can = true;
                    }
                    else if (mas[i+1][j-1] =='.')
                    {
                        if (mas[i+2][j-2] == 'x')
                            can = true;
                    }
                }
            }
        }
        if (can) {
            System.out.println("YES");
        } else System.out.println("NO");

    }

    int[] Z_function(char[] arr) { //начинается как в начале и идёт как в начале
        int n = arr.length;
        int[] z = new int[n];
        z[0] = 0;
        for (int i = 1, l = 0, r = 0; i<n; i++) {
            if (i<=r)
                z[i] = Math.min(r-i+1, z[i-l]);
            while (i+z[i]<n && arr[i+z[i]] == arr[z[i]])
                z[i]++;
            if (i+z[i]-1>r)
            {
                l = i;
                r = i+z[i]-1;
            }
        }
        return z;
    }

    int[] prefix_function(char[] arr) { // оканчивается на этот символ
        int n = arr.length;
        int[] z = new int[n];
        for (int i = 1; i<n; i++) {
            int j = z[i-1];
            while (j>0 && arr[i] != arr[j]) {
                j=z[j-1];
            }
            if (arr[i] == arr[j]) j++;
            z[i] = j;
        }
        return z;
    }

    long substrings_string(char[] arr) {
        int p = 31;
        int n = arr.length;
        long[] pows = new long[n];
        pows[0] = 1;
        for (int i = 1; i<n; i++)
            pows[i] = pows[i-1]*p;
        long[] prefixes = new long[n];
        for (int i = 0; i<n; i++) {
            prefixes[i] = (arr[i]-'a'+1)*pows[i];
            if (i!=0) prefixes[i]+=prefixes[i-1];
        }

        long res = 0;
        for (int l = 1; l<=n; l++) {
            HashSet<Long> hh = new HashSet<>();
            for (int i = 0; i<n-l+1; i++) {
                long cur_hash = prefixes[i+l-1];
                if (i!=0) cur_hash-=prefixes[i-1];
                cur_hash *= pows[n-i-1];
                hh.add(cur_hash);
            }
            res+=hh.size();
        }
        return res;
    }

    void rabin_Karp(char[] t, char[] s) {
        int p = 31;
        long[] p_pow = new long[Math.max(t.length, s.length)];
        p_pow[0] = 1;
        for (int i = 1; i<p_pow.length; i++)
            p_pow[i] = p_pow[i-1]*p;
        long main_hash = 0;
        for (int i = 0; i<s.length; i++)
            main_hash+=(s[i]-'a'+1)*p_pow[i];
        long hashes[] = new long[t.length];
        for (int i = 0; i<t.length; i++) {
            hashes[i] = (t[i]-'a'+1)*p_pow[i];
            if (i!=0) hashes[i]+=hashes[i-1];
        }
        for (int i = 0; i+s.length-1<t.length; i++) {
            long cur_h = hashes[i+s.length-1];
            if (i!=0) cur_h-=hashes[i-1];
            if (cur_h*p_pow[i] == main_hash)
                System.out.println(i);
        }
    }

    int[] podpalindroms(ArrayList<Character> s) {
        int n = s.size();
        int[] d1 = new int[n]; //odd
        int l = 0;
        int r = -1;
        for(int i = 0; i < n; i++) {
            int k;
            if (i > r) k = 1;
            else k = Math.min(d1[l + r - i], r - i);

            while (0 <= i - k && i + k < n && s.get(i - k) == s.get(i + k)) k++;
            d1[i] = k;
            if (i + k - 1 > r) {
                r = i + k - 1;
                l = i - k + 1;
            }
        }
        int[] res = new int[n];
        for (int i = 0; i<n; i++) {
            System.out.print(d1[i] + " ");
            res[i] = d1[i];
        }
        System.out.println();
        return res;
    }

}

class FScanner {
    BufferedReader br;
    StringTokenizer st;
    FScanner(InputStreamReader isr) {
        br = new BufferedReader(isr);
    }

    FScanner(FileReader fr) {
        br = new BufferedReader(fr);
    }

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

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

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

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

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

    char nextChar() throws IOException {
        return (char) br.read();
    }

}


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

public class Main{
  public static void main(String... args)throws IOException{
        Map<Character, Integer> m = new HashMap<Character, Integer>();
        Scanner input = new Scanner (System.in);
        String in = input.next();
        //System.out.println("After conversion: " + in);

        String card1 = input.next() ;
        String  card2 = input.next();

        m.put('T' , 10);
        m.put('J' , 11);
        m.put('Q' , 12);
        m.put('K' , 13);
        m.put('A' , 14);
        boolean same = card1.charAt(1)==card2.charAt(1);
        char c1 = card1.charAt(1);
        char c2 = card2.charAt(1);
        char a = in.charAt(0);
        if(c1 == a&& c2!=a)
            System.out.println("YES");
        else if(c2 == a&& c1!=a)
            System.out.println("NO");
            else{
        //System.out.println("After conversion: " + c1);
        if(same){
int c;
char charInt=card1.charAt(0);
if(charInt>=48 && charInt<=57){
    //System.out.println("not character");
    c = card1.charAt(0) - '0';
}
else{

     c = m.get(charInt);
}
    //System.out.println(c);

int c3;
char charInt2=card2.charAt(0);
//System.out.println("not character" + charInt);
if(charInt2>=48 && charInt2<=57){

    c3 = card2.charAt(0) - '0';
}
else{
   // System.out.println("Character");
     c3 = m.get(charInt2);
}
            //System.out.println(c3);
    if(c > c3)
        System.out.println("YES");
    else
        System.out.println("NO");
    }
            }

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

    }
}


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

public class GFG {

	public static void main (String[] args) {
	PrintWriter pw=new PrintWriter(System.out);
	Scanner sc=new Scanner(System.in);
	int count=0,f=0,j=0,mx=0;
     String s="1123132";
     int a=sc.nextInt(),b=sc.nextInt(),c=sc.nextInt();
     HashMap<Character,Integer> map=new HashMap<>();

     for(int i=0;i<7;i++){
     map.put('1',a);
     map.put('2',b);
     map.put('3',c);
     j=i;
     while(f!=1){
         int t=map.get(s.charAt(j%7));
          if(t==0)
          break;
          t--;
          map.put(s.charAt(j%7),t);
          count++;

        j++;
     }
    mx=Math.max(mx,count);
     count=0;

     }

    pw.println(mx);
	pw.close();

	}
}


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

public class MemSql {

	static int[] arr;
	static int[] com;
	static int[][] dp;

	public static int solve(int i, int opp) {
		if (i == arr.length)
			return com[com.length - 1] - opp;
		if (dp[i][opp] != -1)
			return dp[i][opp];
		int sum = com[i] - opp;
		int Give = solve(i + 1, opp + arr[i]);
		int Take = com[com.length - 1] - (solve(i + 1, sum));
		return dp[i][opp] = Math.max(Give, Take);

	}

	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		arr = new int[N + 1];
		com = new int[N + 1];
		for (int i = 1; i <= N; i++) {
			arr[i] = sc.nextInt();
			com[i] = com[i - 1] + arr[i];
		}
		dp = new int[N + 1][N * 100000 + 1];
		for (int i = 0; i <= N; i++)
			Arrays.fill(dp[i], -1);
		System.out.println(com[N] - solve(1, 0) + " " + solve(1, 0));
	}

	static class Scanner {
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream s) {
			br = new BufferedReader(new InputStreamReader(s));
		}

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

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

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

		public String nextLine() throws IOException {
			return br.readLine();
		}

		public double nextDouble() throws IOException {
			String x = next();
			StringBuilder sb = new StringBuilder("0");
			double res = 0, f = 1;
			boolean dec = false, neg = false;
			int start = 0;
			if (x.charAt(0) == '-') {
				neg = true;
				start++;
			}
			for (int i = start; i < x.length(); i++)
				if (x.charAt(i) == '.') {
					res = Long.parseLong(sb.toString());
					sb = new StringBuilder("0");
					dec = true;
				} else {
					sb.append(x.charAt(i));
					if (dec)
						f *= 10;
				}
			res += Long.parseLong(sb.toString()) / f;
			return res * (neg ? -1 : 1);
		}

		public boolean ready() throws IOException {
			return br.ready();
		}

		public boolean nextEmpty() throws IOException {
			String s = nextLine();
			st = new StringTokenizer(s);
			return s.isEmpty();
		}
	}
}


import java.util.*;

public class Paint
{
    public static void main(String[] args)
    {
        Scanner sc= new Scanner(System.in);
        long[] test=new long[sc.nextLong()];
        Arrays.sort(test);
        long colors=test.length;
        for(int x=0;x<test.length;x++)
        {
            if(test[x]==-1729)
            {
                colors--;
            }
            for(int y=x+1;y<test.length;y++)
            {
                if(test[y]%test[x]==0)
                {
                    test[y]=-1729;
                }
            }
        }
        System.out.println(colors);
    }
}


import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        System.out.println(pred(scan));

    }
    public static long pred(Scanner scan ) {
        long n = scan.nextLong();
        long [] num = new long [(int) (n+1)];

        if(n ==0) return 1;
        num[1] = 7;
        for(int i  = 2;i <= n; i++) {
            num[i] = i+1 + i * 4 + i-1 + num[i-1];

        }
        return num[(int) n] ;

    }

}


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

public class z2 {
    public static PrintWriter pw;
    public static void main(String[] args) throws FileNotFoundException {
        Scanner in = new Scanner(System.in);
        pw = new PrintWriter(System.out);
        long n=in.nextLong();
        long l=in.nextLong()-1;
        long r=in.nextLong()-1;
        ArrayList<Long> ar=rec(n);
        long ans=0;
        for(long i=l;i<=r;i++)ans+=ar.get((int)i);
        pw.print(ans);
        pw.close();

    }
    public static ArrayList<Long> rec(long n){
        ArrayList<Long> ar=new ArrayList<>();
        if(n==1 || n==0){
            ar.add(n);
            return ar;
        }
        ar=rec(n/2);
        ar.add(n%2);
        for(int i=ar.size()-2;i>=0;i--){
            ar.add(ar.get(i));
        }
        return ar;
    }

}


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

public class TestClass {

    public static void main(String args[] ) throws Exception {
		//Scanner hb=new Scanner(System.in);
		InputReader hb=new InputReader(System.in);
		PrintWriter w=new PrintWriter(System.out);

		int n=hb.nextInt();
		int l=hb.nextInt();
		int r=hb.nextInt();

		String s=divide(n);
		//System.out.println(s);
		int count=0;
		for(int i=l-1;i<r;i++)
		{
			if(s.charAt(i)=='1')
				count++;
		}
		System.out.println(count);
    }
	public static String divide(int n)
	{
		if(n==1)
			return "1";
		else if(n==0)
			return "0";
		else
		{
			String s1=divide(n/2);
			String s2=Integer.toString(n%2);
			return s1+s2+s1;
		}
	}
	public static long pow(long n, long p,long mod)
	{
		if(p==0)
			return 1;
		if(p==1)
			return n%mod;
		if(p%2==0)
		{
			long temp=pow(n, p/2,mod);
			return (temp*temp)%mod;
		}
		else
		{
			long temp=pow(n,p/2,mod);
			temp=(temp*temp)%mod;
			return(temp*n)%mod;
		}
	}

	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 String nextLine()
		{
			BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
			String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
		}
		public int nextInt()
		{
			int c = read();

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

			int sgn = 1;

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

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

			return res * sgn;
		}

		public long nextLong()
		{
			int c = read();
			while (isSpaceChar(c))
				c = read();
			int sgn = 1;
			if (c == '-')
			{
				sgn = -1;
				c = read();
			}
			long res = 0;

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

		public double nextDouble()
		{
			int c = read();
			while (isSpaceChar(c))
				c = read();
			int sgn = 1;
			if (c == '-')
			{
				sgn = -1;
				c = read();
			}
			double res = 0;
			while (!isSpaceChar(c) && c != '.')
			{
				if (c == 'e' || c == 'E')
					return res * Math.pow(10, nextInt());
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res *= 10;
				res += c - '0';
				c = read();
			}
			if (c == '.')
			{
				c = read();
				double m = 1;
				while (!isSpaceChar(c))
				{
					if (c == 'e' || c == 'E')
						return res * Math.pow(10, nextInt());
					if (c < '0' || c > '9')
						throw new InputMismatchException();
					m /= 10;
					res += (c - '0') * m;
					c = read();
				}
			}
			return res * sgn;
		}

		public String readString()
		{
			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 boolean isSpaceChar(int c)
		{
			if (filter != null)
				return filter.isSpaceChar(c);
			return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
		}

		public String next()
		{
			return readString();
		}
		public interface SpaceCharFilter
		{
			public boolean isSpaceChar(int ch);
		}
	}
}


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

/**
 *
 * @author haytham
 */
public class Main {

    public static void main(String[] args) throws IOException {
        BufferedReader br=new BufferedReader(new FileReader("x.in"));
//        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        while (br.ready()) {
            String x=br.readLine().trim();
            String y[]=x.split(" +");
            int a=Integer.parseInt(y[0]);
            int b=Integer.parseInt(y[1]);
            int c=Integer.parseInt(y[2]);
            int d=Integer.parseInt(y[3]);
            if((a+b>c&&a+c>b&&b+c>a)||(a+d>c&&a+c>d&&d+c>a)||(d+b>c&&d+c>b&&b+c>d)||(a+b>d&&a+d>b&&b+d>a))
                System.out.println("TRIANGLE");
            else if((a+b>=c&&a+c>=b&&b+c>=a)||(a+d>=c&&a+c>=d&&d+c>=a)||(d+b>=c&&d+c>=b&&b+c>=d)||(a+b>=d&&a+d>=b&&b+d>=a))
                System.out.println("SEGMENT");
            else
                System.out.println("IMPOSSIBLE");

        }

    }

}


/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package javaapplication17;

import java.util.Scanner;

/**
 *
 * @author Lotus
 */
public class B {

    public static void main(String[]args)
    {
        Scanner input = new Scanner (System.in);
        String t  = input.next();
        String ices = input.next();
        int [] counter = new int[9];

            for(int j=0; j<ices.length();j++)
            {

                    if(ices.charAt(j)=='9')
                        counter[6]++;
                    else if(ices.charAt(j)=='5' )
                    {
                         counter[2]++;

                    }
                     else
                    counter[ices.charAt(j)-48]++;

            }
        int count=0;
        int n;
        boolean m=false;
        while(m!=true)
        {
         for(int i=0; i<t.length();i++)
            {

                     if(t.charAt(i)=='9')
                         n=6;

                    else if(t.charAt(i)=='5' )
                    {
                        n=2;

                    }
                     else
                   n=t.charAt(i)-48;

                     counter[n]--;
                   if( counter[n]<0)
                   {
                       m=true;
                       break;

                   }
            }
        if(!m)
         count++;

            }

        System.out.println(count);

    }

}


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

public class R191_Test8_B //Name: Sheldon and Ice Pieces
{
	public static void main(String[] args) {
		Scanner      in = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		solve(in, out);
		out.close();
		in.close();
	}

	public static void solve(Scanner in, PrintWriter out)
	{
		int n = in.nextInt();
		int k = in.nextInt();

		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = in.nextInt();

		String s = in.next();

		StringBuilder sb = new StringBuilder(s + k);
		sb.append("\r\n");

		out.println(sb);
	}
}


import java.util.Scanner;

public class Main {

void go()
    {Scanner s=new Scanner(System.in);
int r=s.nextInt();int g=s.nextInt();int b=s.nextInt();
int time=-1;
if(r==0&&g==0&&b==0)
{time++;
 System.out.println(time);
break();
}
while(r>0||g>0||b>0)

{
    if(r>0)
    {r-=2;time++;}else if(g>0||b>0){time++;}
    if(g>0)
    {g-=2;time++;}else if(b>0){time++;}
if(b>0)
    {b-=2;time++;}

}time+=30;
     System.out.println(time);
}

    public static void main(String[] args) {

Main m=new Main();
m.go();

}
}


import java.io.IOException;
import java.util.InputMismatchException;
import java.io.PrintStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.Writer;
import java.math.BigInteger;
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;
		StreamInputReader in = new StreamInputReader(inputStream);
		OutputWriter out = new OutputWriter(outputStream);
		TaskD solver = new TaskD();
		solver.solve(1, in, out);
		out.close();
	}
}

class TaskD {
    public void solve(int testNumber, StreamInputReader in, OutputWriter out) {
        int n = in.readInt(), m = in.readInt();
        int res = 0;
        for(int i = 0; i < n; ++i) {
            for(int j = 0; j < m; ++j) {
                if (((i+j)&1) == 1) {
                    ++res;
                }
            }
        }
        System.out.println(Math.max(res, n*m -res));
    }
}

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

    public StreamInputReader(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++];
    }

    }

class OutputWriter {
	private final PrintWriter writer;

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

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

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

abstract class InputReader {

	public abstract int read();

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

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

    }


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

public class C {
    static int[] nodes;
    static int[] sums;
    static int[][][] dp;

    public static int f(int i, int mask, int ones) {
        if (i == nodes.length)
            return ones == 0 ? 1 : 0;
        if ((mask & (1 << i)) == 0)
            return 0;
        if (ones < 0)
            return 0;
        if (dp[i][ones][mask] != -1)
            return dp[i][ones][mask];
        int left = (mask) ^ ((1 << nodes.length) - 1);
        int need = nodes[i] - 1;
        int result = 0;
        for (int j = left; j >= 0 && result == 0; j = (j - 1) & left) {
            if (need >= sums[j]) {
                int total = (need - sums[j]) + Integer.bitCount(j);
                if (total >= 2)
                    result |= f(i + 1, mask | j, ones - (need - sums[j]));
            }
            if (j == 0)
                break;
        }
        return dp[i][ones][mask] = result;
    }

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int[] deg = new int[n];
        for (int i = 0; i < n; i++)
            deg[i] = in.nextInt();
        if (n == 1) {
            if (deg[i] == 1)
                System.out.println("YES");
            else
                System.out.println("NO");
            return;
        }
        Arrays.sort(deg);
        int ones = 0;
        for (int i : deg)
            if (i == 1)
                ones++;
        if (ones <= n - ones)
            System.out.println("NO");
        else {
            nodes = new int[n - ones];
            for (int i = 0; i < nodes.length; i++) {
                nodes[i] = deg[n - 1 - i];
            }
            sums = new int[1 << nodes.length];
            for (int i = 0; i < sums.length; i++) {
                for (int j = 0; j < nodes.length; j++)
                    if ((i & (1 << j)) != 0) {
                        sums[i] += nodes[j];
                    }
            }
            dp = new int[13][26][1 << 13];
            for (int[][] a : dp)
                for (int[] b : a)
                    Arrays.fill(b, -1);
            int result = f(0, 1, ones);
            if (result == 1)
                System.out.println("YES");
            else
                System.out.println("NO");
        }
    }
}


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

public class AlyonaAndNumbers {

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

        for (int i = 1; i <= n ; i++) {
          int f = 5;

          while(true){
              if(f-(i%f) <= m && i < f){
                  count++;
                  f = f+5;
              }
              else if(i>=f)
                  f = f+5;

              else
                  break;
          }

    }
        System.out.println(count);

}
}


import java.util.Scanner;
public class Search
{
    public static void main(String[] args)
    {
        Scanner in = new Scanner(System.in);
        String data = in.next();
        data = data.toLowerCase();
        char data_[] = data.toCharArray();
        int size = 0;
        for (int i = 0; i < data_.length; i++)
        {
            if(data_[i]==' '||data_[i]=='?')
            {
                size++;
            }
        }
        char result[] = new char[data_.length-size];
        int j = 0;
        for (int i = 0; i < data_.length; i++)
        {
            if(data_[i]!=' '&&data_[i]!='?')
            {
                result[j]=data_[i];
                j++;
            }

        }
        char glas[] = new char[]{'a','o','e','u','y','i'};
        int sch = 0;
        for (int i = 0; i < glas.length; i++)
        {
            if(glas[i]==result[result.length-1])
            {
                sch++;
            }
        }
        String res = "YES";
        if(sch==1)
        {
            System.out.println(res);
        }
        else
        {
            res = "NO";
            System.out.println(res);
        }
    }

}


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

public class Main {
	public static class BigSquareRoot {
		BigSquareRoot(int mi, int sc) {
			maxIterations = mi;
			scale = sc;
		}

		  private static BigDecimal ZERO = new BigDecimal ("0");
		  private static BigDecimal ONE = new BigDecimal ("1");
		  private static BigDecimal TWO = new BigDecimal ("2");

		  private BigDecimal error;
		  private int iterations;
		  private int scale = 1;
		  private int maxIterations = 1;

		  private static BigDecimal getInitialApproximation (BigDecimal n) {
		    BigInteger integerPart = n.toBigInteger ();
		    int length = integerPart.toString ().length ();
		    if ((length % 2) == 0) {
		      length--;
		    }
		    length /= 2;
		    BigDecimal guess = ONE.movePointRight (length);
		    return guess;
		  }

		  public BigDecimal get (BigDecimal n) {
		    if (n.compareTo (ZERO) <= 0) {
		      throw new IllegalArgumentException ();
		    }
		    BigDecimal initialGuess = getInitialApproximation (n);
		    BigDecimal lastGuess = ZERO;
		    BigDecimal guess = new BigDecimal (initialGuess.toString ());
		    iterations = 0;
		    boolean more = true;
		    while (more) {
		      lastGuess = guess;
		      guess = n.divide(guess, scale, BigDecimal.ROUND_HALF_UP);
		      guess = guess.add(lastGuess);
		      guess = guess.divide (TWO, scale, BigDecimal.ROUND_HALF_UP);
		      error = n.subtract (guess.multiply (guess));
		      if (++iterations >= maxIterations) {
		        more = false;
		      }
		      else if (lastGuess.equals (guess)) {
		        more = error.abs ().compareTo (ONE) >= 0;
		      }
		    }
		    return guess;

		  }
		}

	void solve() throws IOException {
		int pre = 10000, it1 = 10, it2 = 9;
		BigSquareRoot bsr = new BigSquareRoot(it1, pre);
		int rhu = BigDecimal.ROUND_HALF_UP;
		BigDecimal a = BigDecimal.ONE;
		BigDecimal b = BigDecimal.ONE.divide(bsr.get(new BigDecimal("2")), pre, rhu);
		BigDecimal t = BigDecimal.ONE.divide(new BigDecimal("4"), pre, rhu);
		BigDecimal p = BigDecimal.ONE;
		for (int i = 0; i < it2; i++) {
			BigDecimal a1 = a.add(b).divide(new BigDecimal("2"), 20 * i + 20, rhu);
			BigDecimal b1 = bsr.get(a.multiply(b));
			BigDecimal t1 = t.subtract(p.multiply((a.subtract(a1)).pow(2)));
			BigDecimal p1 = p.add(p);
			a = a1;
			b = b1;
			t = t1;
			p = p1;
		}
		BigDecimal pi = (((a.add(b)).pow(2)).divide(new BigDecimal("4"), pre, rhu)).divide(t, pre, rhu);
		out.println(pi);
	}

	public static void main(String[] args) throws IOException {
		if (args.length > 0 && args[0].equals("Abra")) oj = false; else oj = true;
		new Main().run();
	}

	StreamTokenizer in;
	PrintWriter out;
	static boolean oj;
	BufferedReader br;

	void init() throws IOException {
		Reader reader = oj ? new InputStreamReader(System.in) : new FileReader("input.txt");
		Writer writer = oj ? new OutputStreamWriter(System.out) : new FileWriter("output.txt");
		br = new BufferedReader(reader);
		in = new StreamTokenizer(br);
		out = new PrintWriter(writer);
	}

	void run() throws IOException {
		long beginTime = System.currentTimeMillis();
		init();
		solve();
		long endTime = System.currentTimeMillis();
		if (!oj) {
			System.out.println("Running time = " + (endTime - beginTime));
		}
		out.flush();
	}
}


import java.awt.*;
import java.awt.event.*;
import java.awt.geom.*;
import java.io.*;
import java.math.*;
import java.text.*;
import java.util.*;

/*
br = new BufferedReader(new FileReader("input.txt"));
pw = new PrintWriter(new BufferedWriter(new FileWriter("output.txt")));
br = new BufferedReader(new InputStreamReader(System.in));
pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
 */

public class Main {
  private static BufferedReader br;
  private static StringTokenizer st;
  private static PrintWriter pw;

  static String[] list;

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

  static char[][] grid;

  public static void main(String[] args) throws IOException {
    br = new BufferedReader(new InputStreamReader(System.in));
    pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
    //int qq = 1;
    int qq = Integer.MAX_VALUE;
    //int qq = readInt();
    for(int casenum = 1; casenum <= qq; casenum++)  {
      int r = readInt();
      int h = readInt();
      double height = h + r * Math.sqrt(3) / 2;
      int numCircles = (int)(height/r);
      if(numCircles * r + r * Math.sqrt(3) / 2 <= r+h) {
        numCircles *= 2;
        numCircles++;
      }
      else {
        numCircles *= 2;
      }
      pw.println(numCircles);
    }
    pw.close();
  }

  private static void exitImmediately() {
    pw.close();
    System.exit(0);
  }

  private static long readLong() throws IOException {
    return Long.parseLong(nextToken());
  }

  private static double readDouble() throws IOException {
    return Double.parseDouble(nextToken());
  }

  private static int readInt() throws IOException {
    return Integer.parseInt(nextToken());
  }

  private static String nextToken() throws IOException  {
    while(st == null || !st.hasMoreTokens())  {
      if(!br.ready()) {
        exitImmediately();
      }
      st = new StringTokenizer(br.readLine().trim());
    }
    return st.nextToken();
  }
}


import java.util.ArrayList;
import java.util.HashSet;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
import java.util.Arrays;
import java.util.Random;
import java.io.FileWriter;
import java.io.PrintWriter;
/*
    Solution Created: 15:30:24 28/09/2020
    Custom Competitive programming helper.
*/

public class Main {
	static ArrayList<Integer> ans;
	public static void solve(Reader in, Writer out) {
		int t = 1;
		while(t-->0) {
			int n = in.nextInt();
			int[] a = in.na(3);
			int[] b = in.na(3);
			int v2 = s(a,b);
			fix(a, b);
			int v1 = s(a,b);
			out.println(v1+" "+v2);
		}
	}
	public static void fix(int[] a, int[] b) {
		for(int i = 0; i<3*5; i++) {
			int t1 = (i%3), t2 = (i+2)%3;
			if(b[t1]>b[t2]) {
				int mn = Math.min(b[t1], a[i%3]);
				a[i%3]-=mn;
				b[t1]-=mn;
			}else {
				int mn = Math.min(b[t2], a[i%3]);
				a[i%3]-=mn;
				b[t2]-=mn;
			}
		}
	}
	public static int s(int[] a, int[] b) {
		int ans = Math.min(a[0], b[1]);
		ans += Math.min(a[1], b[2]);
		ans += Math.min(a[2], b[0]);
		return ans;
	}
	public static void main(String[] args) {
		Reader in = new Reader();
		Writer out = new Writer();
		solve(in, out);
		out.exit();
	}
}
/*

public class Main {
	static ArrayList<Integer> ans;
	public static void solve(Reader in, Writer out) {
		int t = 1;
		while(t-->0) {
			int n = in.nextInt();
			int[] a = in.na(3);
			int[] b = in.na(3);
			out.println(f(a, b)+" "+s(a,b));
		}
	}
	public static int f(int[] a, int[] b) {
		//r s p
		int ans = 0;
		for(int i = 0; i<9; i++) {
			int t1 = (i%3), t2 = (i+2)%3;
			if(b[t1]>b[t2]) {
				int mn = Math.min(b[t1], a[i%3]);
				a[i%3]-=mn;
				b[t1]-=mn;
			}else {
				int mn = Math.min(b[t2], a[i%3]);
				a[i%3]-=mn;
				b[t2]-=mn;
			}
		}
		Util.dbg(a);
		Util.dbg(b);
		return ans;
	}
	public static int s(int[] a, int[] b) {
		int ans = Math.min(a[0], b[1]);
		ans += Math.min(a[1], b[2]);
		ans += Math.min(a[2], b[0]);
		return ans;
	}
	public static void main(String[] args) {
		Reader in = new Reader();
		Writer out = new Writer();
		solve(in, out);
		out.exit();
	}

static class Reader {
	static BufferedReader br;
	static StringTokenizer st;
	private int charIdx = 0;
	private String s;

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

	public Reader(String f){
		try {
			this.br = new BufferedReader(new FileReader(f));
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

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

	public double[] nd(int n) {
		double[] a = new double[n];
		for (int i = 0; i < n; i++)
			a[i] = nextDouble();
		return a;
	}

	public char nextChar() {
		if (s == null || charIdx >= s.length()) {
			if (st == null || !st.hasMoreTokens())
				try {
					readLine();
				} catch (Exception e) {
				}
			s = st.nextToken();
			charIdx = 0;
		}
		return s.charAt(charIdx++);
	}

	public long[] nl(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nextLong();
		return a;
	}

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

	public String[] nS(int n) {
		String[] a = new String[n];
		for (int i = 0; i < n; i++)
			a[i] = next();
		return a;
	}

	public int nextInt() {
		if (st == null || !st.hasMoreTokens())
			try {
				readLine();
			} catch (Exception e) {
			}
		return Integer.parseInt(st.nextToken());
	}

	public double nextDouble() {
		if (st == null || !st.hasMoreTokens())
			try {
				readLine();
			} catch (Exception e) {
			}
		return Double.parseDouble(st.nextToken());
	}

	public Long nextLong() {
		if (st == null || !st.hasMoreTokens())
			try {
				readLine();
			} catch (Exception e) {
			}
		return Long.parseLong(st.nextToken());
	}

	public String next() {
		if (st == null || !st.hasMoreTokens())
			try {
				readLine();
			} catch (Exception e) {
			}
		return st.nextToken();
	}

	public static void readLine() {
		try {
			st = new StringTokenizer(br.readLine());
		} catch (Exception e) {
		}
	}
}

static class Util{
		private static Random random = new Random();

		public static long modInverse(long a, long MOD) {
			long[] gcdE = gcdExtended(a, MOD);
			if (gcdE[0] != 1) return -1; // Inverted doesn't exist
			long x = gcdE[1];
			return (x % MOD + MOD) % MOD;
		}
		public static long[] gcdExtended(long p, long q) {
			if (q == 0) return new long[] { p, 1, 0 };
			long[] vals = gcdExtended(q, p % q);
			long tmp = vals[2];
			vals[2] = vals[1] - (p / q) * vals[2];
			vals[1] = tmp;
			return vals;
		}
		public void fac(int n) {

		}
		public static boolean isPrime(int n) {
	        if (n <= 1) return false;
	        if (n <= 3) return true;
	        if (n % 2 == 0 || n % 3 == 0) return false;
	        for (int i = 5; i * i <= n; i = i + 6)
	            if (n % i == 0 || n % (i + 2) == 0)
	            return false;
	        return true;
	    }
	    public static int lowerBound(int[] a, int v) {
	    	int l = 0, h = a.length;
	    	while(l<h) {
	    		int mid = (l+h)/2;
	    		if(v<=a[mid]) h = mid;
	    		else l = mid+1;
	    	}
	    	return l;
	    }
	    public static int lowerBound(long[] a, long v) {
	    	int l = 0, h = a.length;
	    	while(l<h) {
	    		int mid = (l+h)/2;
	    		if(v<=a[mid]) h = mid;
	    		else l = mid+1;
	    	}
	    	return l;
	    }
	    public static int upperBound(int[] a, int v) {
	    	int l = 0, h = a.length;
	    	while(l<h) {
	    		int mid = (l+h)/2;
	    		if(a[mid]<=v) l = mid+1;
	    		else h = mid;
	    	}
	    	return l;
	    }
	    public static int upperBound(long[] a, long v) {
	    	int l = 0, h = a.length;
	    	while(l<h) {
	    		int mid = (l+h)/2;
	    		if(a[mid]<=v) l = mid+1;
	    		else h = mid;
	    	}
	    	return l;
	    }
	    public static boolean[] getSieve(int n) {
	        boolean[] isPrime = new boolean[n+1];
	        for (int i = 2; i <= n; i++) isPrime[i] = true;
	        for (int i = 2; i*i <= n; i++) if (isPrime[i])
	                for (int j = i; i*j <= n; j++) isPrime[i*j] = false;
	        return isPrime;
	    }
	    public static int gcd(int a, int b) {
	    	int tmp = 0;
	    	while(b != 0) {
	    		tmp = b;
	    		b = a%b;
	    		a = tmp;
	    	}
	    	return a;
	    }
	    public static long gcd(long a, long b) {
	    	long tmp = 0;
	    	while(b != 0) {
	    		tmp = b;
	    		b = a%b;
	    		a = tmp;
	    	}
	    	return a;
	    }
	    public static int random(int min, int max) {
	    	return random.nextInt(max-min+1)+min;
	    }
		public static void dbg(Object... o) {
			System.out.println(Arrays.deepToString(o));
		}
		public static void reverse(int[] s, int l , int r) {
			for(int i = l; i<=(l+r)/2; i++) {
				int tmp = s[i];
				s[i] = s[r+l-i];
				s[r+l-i] = tmp;
			}
	    }
		public static void reverse(int[] s) {
			reverse(s, 0, s.length-1);
	    }
		public static void reverse(long[] s, int l , int r) {
			for(int i = l; i<=(l+r)/2; i++) {
				long tmp = s[i];
				s[i] = s[r+l-i];
				s[r+l-i] = tmp;
			}
	    }
		public static void reverse(long[] s) {
			reverse(s, 0, s.length-1);
	    }
		public static void reverse(float[] s, int l , int r) {
			for(int i = l; i<=(l+r)/2; i++) {
				float tmp = s[i];
				s[i] = s[r+l-i];
				s[r+l-i] = tmp;
			}
	    }
		public static void reverse(float[] s) {
			reverse(s, 0, s.length-1);
	    }
		public static void reverse(double[] s, int l , int r) {
			for(int i = l; i<=(l+r)/2; i++) {
				double tmp = s[i];
				s[i] = s[r+l-i];
				s[r+l-i] = tmp;
			}
	    }
		public static void reverse(double[] s) {
			reverse(s, 0, s.length-1);
	    }
		public static void reverse(char[] s, int l , int r) {
			for(int i = l; i<=(l+r)/2; i++) {
				char tmp = s[i];
				s[i] = s[r+l-i];
				s[r+l-i] = tmp;
			}
	    }
		public static void reverse(char[] s) {
			reverse(s, 0, s.length-1);
	    }
		public static <T> void reverse(T[] s, int l , int r) {
			for(int i = l; i<=(l+r)/2; i++) {
				T tmp = s[i];
				s[i] = s[r+l-i];
				s[r+l-i] = tmp;
			}
	    }
		public static <T> void reverse(T[] s) {
			reverse(s, 0, s.length-1);
	    }
		public static void shuffle(int[] s) {
	        for (int i = 0; i < s.length; ++i) {
	            int j = random.nextInt(i + 1);
	            int t = s[i];
	            s[i] = s[j];
	            s[j] = t;
	        }
	    }
	    public static void shuffle(long[] s) {
	        for (int i = 0; i < s.length; ++i) {
	            int j = random.nextInt(i + 1);
	            long t = s[i];
	            s[i] = s[j];
	            s[j] = t;
	        }
	    }
	    public static void shuffle(float[] s) {
	        for (int i = 0; i < s.length; ++i) {
	            int j = random.nextInt(i + 1);
	            float t = s[i];
	            s[i] = s[j];
	            s[j] = t;
	        }
	    }
	    public static void shuffle(double[] s) {
	        for (int i = 0; i < s.length; ++i) {
	            int j = random.nextInt(i + 1);
	            double t = s[i];
	            s[i] = s[j];
	            s[j] = t;
	        }
	    }
	    public static void shuffle(char[] s) {
	        for (int i = 0; i < s.length; ++i) {
	            int j = random.nextInt(i + 1);
	            char t = s[i];
	            s[i] = s[j];
	            s[j] = t;
	        }
	    }
	    public static <T> void shuffle(T[] s) {
	        for (int i = 0; i < s.length; ++i) {
	            int j = random.nextInt(i + 1);
	            T t = s[i];
	            s[i] = s[j];
	            s[j] = t;
	        }
	    }
		public static void sortArray(int[] a) {
	        shuffle(a);
	        Arrays.sort(a);
	    }
		public static void sortArray(long[] a) {
			shuffle(a);
	        Arrays.sort(a);
	    }
		public static void sortArray(float[] a) {
			shuffle(a);
	        Arrays.sort(a);
	    }
		public static void sortArray(double[] a) {
			shuffle(a);
	        Arrays.sort(a);
	    }
		public static void sortArray(char[] a) {
			shuffle(a);
	        Arrays.sort(a);
	    }
		public static <T extends Comparable<T>> void sortArray(T[] a) {
	        Arrays.sort(a);
	    }
	}

static class Writer {
	private PrintWriter pw;
	public Writer(){
		pw = new PrintWriter(System.out);
	}

	public Writer(String f){
		try {
			pw = new PrintWriter(new FileWriter(f));
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

	public void printArray(int[] a) {
		for(int i = 0; i<a.length; i++) print(a[i]+" ");
	}
	public void printlnArray(int[] a) {
		for(int i = 0; i<a.length; i++) print(a[i]+" ");
		pw.println();
	}
	public void printArray(long[] a) {
		for(int i = 0; i<a.length; i++) print(a[i]+" ");
	}
	public void printlnArray(long[] a) {
		for(int i = 0; i<a.length; i++) print(a[i]+" ");
		pw.println();
	}
	public void print(Object o) {
		pw.print(o.toString());
	}
	public void println(Object o) {
		pw.println(o.toString());
	}
	public void println() {
		pw.println();
	}
	public void flush() {
		pw.flush();
	}
	public void exit() {
		pw.close();
	}
}
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;;
import java.util.StringTokenizer;
public class rps
{
    public static void main(String args[])
    {
        FastReader sc=new FastReader();
        int n=sc.nextInt();
        int game[]=new int[6],index;
        game[0]=sc.nextInt();
        game[1]=sc.nextInt();
        game[2]=sc.nextInt();
        game[3]=sc.nextInt();
        game[4]=sc.nextInt();
        game[5]=sc.nextInt();
        int maxWin=Math.min(game[0],game[4])+Math.min(game[1],game[5])+Math.min(game[2],game[3]);
        //rock
        //319
        //10 53 256
        //182 103 34
        int minWin=n-(Math.min(game[0],(game[3]+game[5]))+Math.min(game[1],(game[4]+game[3])+Math.min(game[2],(game[4]+game[5]));
        System.out.println(minWin+" "+maxWin);
    }
}
class FastReader
{
    BufferedReader br;
    StringTokenizer st;
    public FastReader()
    {
        br = new BufferedReader(new
        InputStreamReader(System.in));
    }
    String next()
    {
        while (st == null || !st.hasMoreElements())
        {
            try
            {
                st = new StringTokenizer(br.readLine());
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
        }
        return st.nextToken();
    }
    int nextInt()
    {
        return Integer.parseInt(next());
    }
    long nextLong()
    {
        return Long.parseLong(next());
    }
    double nextDouble()
    {
        return Double.parseDouble(next());
    }
    String nextLine()
    {
        String str = "";
        try
        {
            str = br.readLine();
        }
        catch (IOException e)
        {
            e.printStackTrace();
        }
        return str;
    }
}


import java.util.*;

public class Main{
    public static void main(String args[]){
        scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int prev = sc.nextInt();
        int x = sc.nextInt();
        int cd = x-prev;
        prev = x;
        boolean ap = true;
        for(int i=1 ; i<=n-2 ; i++){
            int p = sc.nextInt();
            if((p-prev) != cd){
                ap=false;
            }
            prev = p;
        }
        if(ap==true)
            System.out.println(p+cd);
        else
            System.out.println(p);
    }
}


import java.io.BufferedReader;

import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
import java.util.StringTokenizer;

import lCALE.A;

			public class MMAIN {

					static final int MAX = (int)1e5;
					public static void main(String[] args) throws FileNotFoundException {

							MyScanner scanner = new MyScanner();
							PrintWriter out = new PrintWriter(System.out);

							int n = scanner.nextInt();
							int[] a = new int[n];

							int[] b = new int[101];
							for(int i = 0; i < n; ++i) {
								a[i] = scanner.nextInt();
							}

							loop:
							for(int i = 0; i < n; ++i) {

								int d = -1;
								for(int j = 0; j < n ; ++j) {
									if(a[i] == a[j]) continue;
									else if(d == -1) {
										d = Math.abs(a[i] - a[j]);
									}else {
										if(Math.abs(a[i] - a[j]) != Math.abs(d)) {
											continue loop;
										}
									}
								}

								System.out.println(Math.abs(d));
								return;
							}

							System.out.println(-1);

							out.close();
					}

					static class MyScanner {
								BufferedReader br;
								StringTokenizer st;

								public MyScanner() throws FileNotFoundException {
								  // br = new BufferedReader	(new InputStreamReader(new FileInputStream("input.txt")));
									br = new BufferedReader(new InputStreamReader(System.in));
								}

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

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

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

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

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


import java.util.Scanner;
public class TesT{
    public static void main(String[] args){
        String string = "";
        int counter = 1;
        int result = 0;
        Scanner scanner = new Scanner(System.in);
        string = scanner.next();
        for (int i = 1; i < string.length(); i++){
            if(string.charAt(i) == string.charAt(i-1)){
                counter++;
            }
            else{
                result += (counter+4)/5;
                counter = 1;
            }
        }
        result += (counter+4)/5;
        System.out.prinln(result);
    }
}


import java.util.Scanner;

/**
 *
 * @author takhi
 */
public class lkydiv_122A {
    public static void main(String args[]){
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int flag=0;
       String x=Integer.toString(n);
      while(n>1){
       for(int i=0;i<x.length();i++){
           if(x.charAt(i)=='4'||x.charAt(i)=='7'){
               flag=1;
           }
           else{
               flag=0;
               outer:break;
           }
       }
       if(flag==0){
           if((n%4==0||n%7==0)&&((n/4)%2==0)||(n/7)%2==0){
               flag=1;
           }else{
               System.out.println("NO");
       }
       }if(flag==1){
           System.out.println("YES");
       }
    }
      System.out.println("NO");
    }
}


import java.io.InputStreamReader;
import java.io.IOException;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.io.BufferedReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.Reader;
import java.io.Writer;
import java.io.InputStream;

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

class TaskD {
    public void solve(int testNumber, FastScanner in, FastPrinter out) {
        int n = in.nextInt();
        int m = in.nextInt();
        out.println(solve(n, m));
    }

    static final int MOD = 1000000007;

//    static int solveStupid(int n, int m) {
//        int[][][][][] dp = new int[m][2][2][n][n];
//        for (int i = 0; i < n; i++) {
//            for (int j = i; j < n; j++) {
//                dp[0][0][0][i][j] = 1;
//            }
//        }
//        for (int s = 1; s < m; s++) {
//            for (int i = 0; i < n; i++) {
//                for (int j = 0; j < m; j++) {
//
//                }
//            }
//        }
//    }

    static int solve(int n, int m) {
        int[][][][] dp = new int[2][2][n][n];
        int[][][][] next = new int[2][2][n][n];
        int ans = 0;
        for (int i = 0; i < m; i++) {
            for (int a = 0; a < 2; a++) {
                for (int b = 0; b < 2; b++) {
                    makePart(dp[a][b], n, n);
                    for (int[] d : next[a][b]) {
                        Arrays.fill(d, 0);
                    }
                }
            }
            {
                int[][] n00 = next[0][0];
                int[][] n01 = next[0][1];
                int[][] n10 = next[1][0];
                int[][] n11 = next[1][1];
                int[][] d00 = dp[0][0];
                int[][] d11 = dp[1][1];
                int[][] d10 = dp[1][0];
                int[][] d01 = dp[0][1];
                for (int c = 0; c < n; c++) {
                    for (int d = c; d < n; d++) {
                        n00[c][d] = getSum(d00, c, d + 1, c, d + 1);
                        n01[c][d] = getSum(d00, c, d + 1, d + 1, n) + getSum(d01, c, d + 1, d, n);
                        if (n01[c][d] >= MOD) {
                            n01[c][d] -= MOD;
                        }
                        n10[c][d] = getSum(d00, 0, c, c, d + 1) + getSum(d10, 0, c + 1, c, d + 1);
                        if (n10[c][d] >= MOD) {
                            n10[c][d] -= MOD;
                        }
                        int z = getSum(d00, 0, c, d + 1, n) + getSum(d01, 0, c, d, n);
                        if (z >= MOD) {
                            z -= MOD;
                        }
                        z += getSum(d10, 0, c + 1, d + 1, n) + getSum(d11, 0, c + 1, d, n);
                        if (z >= MOD) {
                            z -= MOD;
                        }
                        n11[c][d] = z;
                    }
                }
            }
            int[][] n00 = next[0][0];
            for (int c = 0; c < n; c++) {
                for (int d = c; d < n; d++) {
                    n00[c][d]++;
                    if (n00[c][d] >= MOD) {
                        n00[c][d] -= MOD;
                    }
                }
            }
            for (int a = 0; a < 2; a++) {
                for (int b = 0; b < 2; b++) {
                    int[][] nab = next[a][b];
                    for (int c = 0; c < n; c++) {
                        for (int d = 0; d < n; d++) {
                            ans += nab[c][d];
                            if (ans >= MOD) {
                                ans -= MOD;
                            }
                        }
                    }
                }
            }
            int[][][][] t = dp;
            dp = next;
            next = t;
        }
        return ans;
    }

    static void makePart(int[][] a, int b, int c) {
        for (int i = 1; i < b; i++) {
            for (int j = 0; j < c; j++) {
                a[i][j] += a[i - 1][j];
                if (a[i][j] >= MOD) {
                    a[i][j] -= MOD;
                }
            }
        }
        for (int i = 0; i < b; i++) {
            for (int j = 1; j < c; j++) {
                a[i][j] += a[i][j - 1];
                if (a[i][j] >= MOD) {
                    a[i][j] -= MOD;
                }
            }
        }
    }

    static int getSum(int[][] a, int x1, int x2, int y1, int y2) {
        if (x1 >= x2 || y1 >= y2) return 0;
        int ret = a[x2 - 1][y2 - 1];
        if (x1 > 0) {
            ret -= a[x1 - 1][y2 - 1];
            if (ret < 0) ret += MOD;
        }
        if (y1 > 0) {
            ret -= a[x2 - 1][y1 - 1];
            if (ret < 0) ret += MOD;
        }
        if (x1 > 0 && y1 > 0) {
            ret += a[x1 - 1][y1 - 1];
            if (ret >= MOD) ret -= MOD;
        }
        return ret;
    }
}

class FastScanner extends BufferedReader {

    boolean isEOF;

    public FastScanner(InputStream is) {
        super(new InputStreamReader(is));
    }

    public int read() {
        try {
            int ret = super.read();
            if (isEOF && ret < 0) {
                throw new InputMismatchException();
            }
            isEOF = ret == -1;
            return ret;
        } catch (IOException e) {
            throw new InputMismatchException();
        }
    }

    static boolean isWhiteSpace(int c) {
        return c >= -1 && c <= 32;
    }

    public int nextInt() {
        int c = read();
        while (isWhiteSpace(c)) {
            c = read();
        }
        int sgn = 1;
        if (c == '-') {
            sgn = -1;
            c = read();
        }
        int ret = 0;
        while (!isWhiteSpace(c)) {
            if (c < '0' || c > '9') {
                throw new NumberFormatException("digit expected " + (char) c
                        + " found");
            }
            ret = ret * 10 + c - '0';
            c = read();
        }
        return ret * sgn;
    }

    }

class FastPrinter extends PrintWriter {

    public FastPrinter(OutputStream out) {
        super(out);
    }

    public FastPrinter(Writer out) {
        super(out);
    }

}