import java.util.Scanner;

public class Main {

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

        long max = 0;

        if (edges == 0) {
            System.out.println(vertexes + " " + vertexes);
            return;
        }

        for (long i = 1; i < vertexes; i++) {
           long currentEdges = (i * (i - 1)) / 2;
            if (currentEdges >= edges) {
                max = vertexes - i;
                break;
            }
        }

        for (long i = 0; i < edges; i++) {
            vertexes -= 2;

            if (vertexes < 0) {
                break;
            }
        }

        vertexes = vertexes > 0 ? vertexes : 0;

        System.out.println(vertexes + " " + max);
    }
}


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

/* Name of the class has to be "Main" only if the class is public. */
public class Codechef
{
	public static void main (String[] args) throws java.lang.Exception
	{
	    Scanner sc=new Scanner(System.in);
	    long n=sc.nextLong();
	    long m=sc.nextLong();
	    if(n==1){
	        System.out.println("1");
	    }else{
	        if(m-1<n-m){
	            System.out.println(m+1);
	        }else{
	            System.out.println(m-1);
	        }
	    }

	}
}


import java.io.*;

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

    StreamTokenizer in;
    PrintWriter out;

    private void run() throws IOException {
        String dir = System.getProperty("user.dir");
        boolean oj = System.getProperty("user.name").equals("kk");

        in = new StreamTokenizer(new BufferedReader(oj ? new FileReader("input.txt") : new InputStreamReader(System.in)));
        //out = new PrintWriter(!oj ? new OutputStreamWriter(System.out) : new FileWriter("output.txt"));
        out = new PrintWriter(new OutputStreamWriter(System.out));
        solve();
        out.flush();
    }

    private double nextDouble() throws IOException {
        in.nextToken();
        return (double) in.nval;
    }

    private long nextLong() throws IOException {
        in.nextToken();
        return (long) in.nval;
    }

    private int nextInt() throws IOException {
        in.nextToken();
        return (int) in.nval;
    }

    private String nextWord() throws IOException {
        in.nextToken();
        return (String) in.sval;
    }

    private void solve() throws IOException {
        //ПРИВЕТ МЫ ПИШЕМ СДЕСЬ
        int n = nextInt();
        String [] names = {"Sheldon", "Leonard", "Penny", "Rajesh", "Howard"};

//
        int sum = 0;
        int i =0;
        while (sum+5*(int)(Math.pow(2,i))<n) {
            sum+=5*(int)(Math.pow(2,i));
            i++;
        }

        int answer = 0;
        while (sum  < n) {
            sum+=(int)(Math.pow(2,i));
            answer++;
        }

        System.out.print(names[answer-1]);

    }
}


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

public class PanoramixsPrediction {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int m = sc.nextInt();
    Integer[] a = new Integer[] {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47};
    List<Integer> primes = Arrays.asList(a);
    if (primes.indexOf(n) + 1 < primes.size() && primes.get(primes.indexOf(n) + 1) == m) {
      System.out.println("YES");
    } else {
      System.out.println("NO");
    }
    sc.close();
  }
}


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

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

public class cf998b {

    public static void main(String[] args) throws IOException {
        int n = rni(), b = ni(), a[] = ria(n), bal[] = new int[n];
        for(int i = 0; i < n; ++i) {
            if(i == 0) {
                bal[i] = a[i] % 2 == 0 ? 1 : -1;
            } else {
                bal[i] = bal[i - 1] + (a[i] % 2 == 0 ? 1 : -1);
            }
        }
        PriorityQueue<Integer> pq = new PriorityQueue<>();
        for(int i = 1; i < n - 1; ++i) {
            if(bal[i] == 0) {
                pq.offer(abs(a[i + 1] - a[i]));
            }
        }
        int ans = 0;
        while(!pq.isEmpty() && b >= pq.peek()) {
            b -= pq.poll();
            ++ans;
        }
        prln(ans);
        close();
    }

    static BufferedReader __in = new BufferedReader(new InputStreamReader(System.in));
    static PrintWriter __out = new PrintWriter(new OutputStreamWriter(System.out));
    static StringTokenizer input;
    static Random __rand = new Random();

    // references
    // IBIG = 1e9 + 7
    // IMAX ~= 2e10
    // LMAX ~= 9e18

    // constants
    static final int IBIG = 1000000007;
    static final int IMAX = 2147483647;
    static final int IMIN = -2147483648;
    static final long LMAX = 9223372036854775807L;
    static final long LMIN = -9223372036854775808L;
    // math util
    static int minof(int a, int b, int c) {return min(a, min(b, c));}
    static int minof(int... x) {if(x.length == 1) return x[0]; if(x.length == 2) return min(x[0], x[1]); if(x.length == 3) return min(x[0], min(x[1], x[2])); int min = x[0]; for(int i = 1; i < x.length; ++i) if(x[i] < min) min = x[i]; return min;}
    static long minof(long a, long b, long c) {return min(a, min(b, c));}
    static long minof(long... x) {if(x.length == 1) return x[0]; if(x.length == 2) return min(x[0], x[1]); if(x.length == 3) return min(x[0], min(x[1], x[2])); long min = x[0]; for(int i = 1; i < x.length; ++i) if(x[i] < min) min = x[i]; return min;}
    static int maxof(int a, int b, int c) {return max(a, max(b, c));}
    static int maxof(int... x) {if(x.length == 1) return x[0]; if(x.length == 2) return max(x[0], x[1]); if(x.length == 3) return max(x[0], max(x[1], x[2])); int max = x[0]; for(int i = 1; i < x.length; ++i) if(x[i] > max) max = x[i]; return max;}
    static long maxof(long a, long b, long c) {return max(a, max(b, c));}
    static long maxof(long... x) {if(x.length == 1) return x[0]; if(x.length == 2) return max(x[0], x[1]); if(x.length == 3) return max(x[0], max(x[1], x[2])); long max = x[0]; for(int i = 1; i < x.length; ++i) if(x[i] > max) max = x[i]; return max;}
    static int powi(int a, int b) {if(a == 0) return 0; int ans = 1; while(b > 0) {if((b & 1) > 0) ans *= a; a *= a; b >>= 1;} return ans;}
    static long powl(long a, int b) {if(a == 0) return 0; long ans = 1; while(b > 0) {if((b & 1) > 0) ans *= a; a *= a; b >>= 1;} return ans;}
    static int fli(double d) {return (int)d;}
    static int cei(double d) {return (int)ceil(d);}
    static long fll(double d) {return (long)d;}
    static long cel(double d) {return (long)ceil(d);}
    static int gcf(int a, int b) {return b == 0 ? a : gcf(b, a % b);}
    static long gcf(long a, long b) {return b == 0 ? a : gcf(b, a % b);}
    static int randInt(int min, int max) {return __rand.nextInt(max - min + 1) + min;}
    static long hash(long x) {x += 0x9e3779b97f4a7c15L; x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9L; x = (x ^ (x >> 27)) * 0x94d049bb133111ebL; return x ^ (x >> 31);}
    // array util
    static void reverse(int[] a) {for(int i = 0, n = a.length, half = n / 2; i < half; ++i) {int swap = a[i]; a[i] = a[n - i - 1]; a[n - i - 1] = swap;}}
    static void reverse(long[] a) {for(int i = 0, n = a.length, half = n / 2; i < half; ++i) {long swap = a[i]; a[i] = a[n - i - 1]; a[n - i - 1] = swap;}}
    static void reverse(char[] a) {for(int i = 0, n = a.length, half = n / 2; i < half; ++i) {char swap = a[i]; a[i] = a[n - i - 1]; a[n - i - 1] = swap;}}
    static void shuffle(int[] a) {int n = a.length - 1; for(int i = 0; i < n; ++i) {int ind = randInt(i, n); int swap = a[i]; a[i] = a[ind]; a[ind] = swap;}}
    static void shuffle(long[] a) {int n = a.length - 1; for(int i = 0; i < n; ++i) {int ind = randInt(i, n); long swap = a[i]; a[i] = a[ind]; a[ind] = swap;}}
    static void rsort(int[] a) {shuffle(a); sort(a);}
    static void rsort(long[] a) {shuffle(a); sort(a);}
    static int[] copy(int[] a) {int[] ans = new int[a.length]; for(int i = 0; i < a.length; ++i) ans[i] = a[i]; return ans;}
    static long[] copy(long[] a) {long[] ans = new long[a.length]; for(int i = 0; i < a.length; ++i) ans[i] = a[i]; return ans;}
    static char[] copy(char[] a) {char[] ans = new char[a.length]; for(int i = 0; i < a.length; ++i) ans[i] = a[i]; return ans;}
    static int[] sorted(int[] a) {int[] ans = copy(a); sort(ans); return ans;}
    static long[] sorted(long[] a) {long[] ans = copy(a); sort(ans); return ans;}
    static int[] rsorted(int[] a) {int[] ans = copy(a); rsort(ans); return ans;}
    static long[] rsorted(long[] a) {long[] ans = copy(a); rsort(ans); return ans;}
    // graph util
    static List<List<Integer>> graph(int n) {List<List<Integer>> g = new ArrayList<>(); for(int i = 0; i < n; ++i) g.add(new ArrayList<>()); return g;}
    static List<List<Integer>> graph(List<List<Integer>> g, int m) throws IOException {for(int i = 0; i < m; ++i) connect(g, rni() - 1, ni() - 1); return g;}
    static List<List<Integer>> graph(int n, int m) throws IOException {return graph(graph(n), m);}
    static List<List<Integer>> dgraph(List<List<Integer>> g, int m) throws IOException {for(int i = 0; i < m; ++i) connecto(g, rni() - 1, ni() - 1); return g;}
    static List<List<Integer>> dgraph(List<List<Integer>> g, int n, int m) throws IOException {return dgraph(graph(n), m);}
    static List<Set<Integer>> sgraph(int n) {List<Set<Integer>> g = new ArrayList<>(); for(int i = 0; i < n; ++i) g.add(new HashSet<>()); return g;}
    static List<Set<Integer>> sgraph(List<Set<Integer>> g, int m) throws IOException {for(int i = 0; i < m; ++i) connect(g, rni() - 1, ni() - 1); return g;}
    static List<Set<Integer>> sgraph(int n, int m) throws IOException {return sgraph(sgraph(n), m);}
    static List<Set<Integer>> dsgraph(List<Set<Integer>> g, int m) throws IOException {for(int i = 0; i < m; ++i) connecto(g, rni() - 1, ni() - 1); return g;}
    static List<Set<Integer>> dsgraph(List<Set<Integer>> g, int n, int m) throws IOException {return dsgraph(sgraph(n), m);}
    static void connect(List<? extends Collection<Integer>> g, int u, int v) {g.get(u).add(v); g.get(v).add(u);}
    static void connecto(List<? extends Collection<Integer>> g, int u, int v) {g.get(u).add(v);}
    static void dconnect(List<? extends Collection<Integer>> g, int u, int v) {g.get(u).remove(v); g.get(v).remove(u);}
    static void dconnecto(List<? extends Collection<Integer>> g, int u, int v) {g.get(u).remove(v);}
    // input
    static void r() throws IOException {input = new StringTokenizer(__in.readLine());}
    static int ri() throws IOException {return Integer.parseInt(__in.readLine());}
    static long rl() throws IOException {return Long.parseLong(__in.readLine());}
    static int[] ria(int n) throws IOException {int[] a = new int[n]; input = new StringTokenizer(__in.readLine()); for(int i = 0; i < n; ++i) a[i] = Integer.parseInt(input.nextToken()); return a;}
    static int[] riam1(int n) throws IOException {int[] a = new int[n]; input = new StringTokenizer(__in.readLine()); for(int i = 0; i < n; ++i) a[i] = Integer.parseInt(input.nextToken()) - 1; return a;}
    static long[] rla(int n) throws IOException {long[] a = new long[n]; input = new StringTokenizer(__in.readLine()); for(int i = 0; i < n; ++i) a[i] = Long.parseLong(input.nextToken()); return a;}
    static char[] rcha() throws IOException {return __in.readLine().toCharArray();}
    static String rline() throws IOException {return __in.readLine();}
    static int rni() throws IOException {input = new StringTokenizer(__in.readLine()); return Integer.parseInt(input.nextToken());}
    static int ni() {return Integer.parseInt(input.nextToken());}
    static long rnl() throws IOException {input = new StringTokenizer(__in.readLine()); return Long.parseLong(input.nextToken());}
    static long nl() {return Long.parseLong(input.nextToken());}
    // output
    static void pr(int i) {__out.print(i);}
    static void prln(int i) {__out.println(i);}
    static void pr(long l) {__out.print(l);}
    static void prln(long l) {__out.println(l);}
    static void pr(double d) {__out.print(d);}
    static void prln(double d) {__out.println(d);}
    static void pr(char c) {__out.print(c);}
    static void prln(char c) {__out.println(c);}
    static void pr(char[] s) {__out.print(new String(s));}
    static void prln(char[] s) {__out.println(new String(s));}
    static void pr(String s) {__out.print(s);}
    static void prln(String s) {__out.println(s);}
    static void pr(Object o) {__out.print(o);}
    static void prln(Object o) {__out.println(o);}
    static void prln() {__out.println();}
    static void pryes() {__out.println("yes");}
    static void pry() {__out.println("Yes");}
    static void prY() {__out.println("YES");}
    static void prno() {__out.println("no");}
    static void prn() {__out.println("No");}
    static void prN() {__out.println("NO");}
    static void pryesno(boolean b) {__out.println(b ? "yes" : "no");};
    static void pryn(boolean b) {__out.println(b ? "Yes" : "No");}
    static void prYN(boolean b) {__out.println(b ? "YES" : "NO");}
    static void prln(int... a) {for(int i = 0, len = a.length - 1; i < len; __out.print(a[i]), __out.print(' '), ++i); __out.println(a[a.length - 1]);}
    static void prln(long... a) {for(int i = 0, len = a.length - 1; i < len; __out.print(a[i]), __out.print(' '), ++i); __out.println(a[a.length - 1]);}
    static <T> void prln(Collection<T> c) {int n = c.size() - 1; Iterator<T> iter = c.iterator(); for(int i = 0; i < n; __out.print(iter.next()), __out.print(' '), ++i); if(n >= 0) __out.println(iter.next()); else __out.println();}
    static void h() {__out.println("hlfd");}
    static void flush() {__out.flush();}
    static void close() {__out.close();}
}


import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class Codeforces409B implements Runnable {
	public static void main(String[] args) {
		new Codeforces409B().run();
	}
	final static int MOD = 1000000000+7;
	public void run() {
		Scanner in = new Scanner(System.in);
		int N = in.nextInt();
		int K = in.nextInt();
		int[][] dp = new int[2][N+1];

		List<Integer>[] divs = new List[N+1];
		for (int n = 1; n <= N; n++) {
			divs[n] = new ArrayList<>();
			for (int d = 1; d <= n; d++) {
				if (n%d == 0)
					divs[n].add(d);
			}
		}

		// k = 1
		for (int n = 1; n <= N; n++) {
			dp[1][n] = 1;
		}
		for (int k = 2; k <= K; k++) {
			Arrays.fill(dp[k&1], 0);
			dp[k&1][1] = 1;
			for (int n = 2; n <= N; n++) {
				for (int d : divs[n]) {
					dp[k&1][n] += dp[(k-1)&1][d];
					dp[k&1][n] %= MOD;
				}
//				for (int d = 1; d <= n; d++) {
//					if (n % d == 0) {
//						dp[k&1][n] += dp[(k-1)&1][d];
//						// TODO: MOD
//					}
//				}
			}
		}

//		for (int[] row : dp)
//			System.out.println(Arrays.toString(row));

		int res = 0;
		for (int n = 1; n <= N; n++) {
			res += dp[K&1][n];
			res %= MOD;
		}
		System.out.println(res);
	}
}


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

public class A {

	private void work() {
		Scanner sc = new Scanner(new BufferedReader(new InputStreamReader(
				System.in)));
		String[] a = { "Hanako", "Ciel" };
		while (sc.hasNextInt()) {
			int x = sc.nextInt();
			int y = sc.nextInt();
			int cur = 0;
			while (10 * x + y >= 22 && y > 1) {
				if (cur == 0) {
					if (x >= 2) {
						x -= 2;
						y -= 2;
					} else if (x == 1) {
						x--;
						y -= 12;
					} else {
						y -= 22;
					}
				} else {
					if (y >= 22) {
						y -= 22;
					} else if (y >= 12) {
						y -= 12;
						x--;
					} else {
						y -= 2;
						x -= 2;
					}
				}
				cur = 1 - cur;
			}
			System.out.println(a[cur]);
		}
	}

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

}


import java.util.*;
import java.math.*;
import java.io.*;
public class FoodOnThePlane {
	public static void main(String args[]) throws Exception {
		BufferedReader s = new BufferedReader(new InputStreamReader(System.in));
		//BufferedReader s = new BufferedReader(new FileReader("*.in"));
		//PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter("*.out")));
		//StringTokenizer st = new StringTokenizer(s.readLine());
		String y = s.readLine();
		long row = Long.parseLong(y.substring(0, y.length()-1));
		int col = y.charAt(y.length()-1) - 'a';
		long secs = 0;
		if(row == 1)secs = 0;
		else if (row == 2)secs = 7;
		else {
			long remainder = row % 4;
			if(remainder == 1){
				secs = ((row - 1) / 4) * 16;
			} else if (remainder == 3){
				secs = ((row - 3)/4) * 16;
			} else if (remainder == 2){
				secs = ((((row + 2) / 4)-1) * 16)+7;
			} else {
				secs = (((row / 4)-1) * 16)+7;
			}
		}
		if(col == 0){
			secs += 4;
		} else if(col == 1){
			secs += 5;
		} else if(col == 2){
			secs += 6;
		} else if(col == 3){
			secs += 3;
		} else if(col == 4){
			secs += 2;
		} else {
			secs+=1;
		}
		System.out.println(secs);
	}
}


import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {
 public static void main(String[] args) {
        Scanner lector = new Scanner(System.in);
        PriorityQueue<Integer> list = new PriorityQueue();
        String s = lector.next();
        int x;

        for(char c:s.toCharArray()){
            if(c!='+'){
                list.add(c-48);
            }
        }

        x = list.size();

        for (int i = 0; i < (x-1); i++) {
             System.out.print(list.poll()+"+");
        }
            System.out.println(list.poll());
    } }
// 1509316386944


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

/**
 * 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;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB
    {
        public void solve(int testNumber, Scanner in, PrintWriter out)
        {
            String S = in.next(), previousS = "";
            int K = in.nextInt();
            while (K > 0)
            {
                int moves[] = getMoves(S);
                int pos = S.length() - 1;
                int cost = 0;
                int winner = -1;
                for (int i = 0; i < moves.length; i++)
                {
                    if (moves[i] == 0) continue;
                    if (pos >= i - Math.min(K, moves[i]))
                    {
                        pos = i - moves[i];
                        cost = Math.min(K, moves[i]);
                        winner = i;
                    }
                }
                S = swap(S, winner, cost);
                K -= cost;

                if (S.equals(previousS)) break;
                previousS = S;
            }
            out.println(S);
        }

        private String swap(String S, int winner, int cost)
        {
            char chars[] = S.toCharArray();
            for (int i = winner; i >= 0 & cost > 0; cost--, i--)
            {
                char t = chars[i - 1];
                chars[i - 1] = chars[i];
                chars[i] = t;
            }
            return new String(chars);
        }

        private int[] getMoves(String S)
        {
            int moves[] = new int[S.length()];
            for (int i = S.length() - 1; i >= 0; i--)
            {
                int move = 0;
                for (int j = i - 1; j >= 0; j--)
                {
                    if (S.charAt(i) > S.charAt(j)) move++;
                    else break;
                }
                moves[i] = move;
            }
            return moves;
        }

    }
}


import java.util.Scanner;

public class A_216_Tiling_with_Hexagons {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		System.out.println(b * c + (a - 1) * c + (a - 1) * (b - 1));
	}
}


import java.util.*;

public class Factory {

    public static void main(String[] args) {

        int a, m, x;
        Scanner scan = new Scanner(System.in);

        a = scan.nextInt();
        m = scan.nextInt();

        for (int i=1; i<=10000; i++) {

            x = a%m;
            if ((x+a) % m == 0){

            System.out.println("Yes");
            return ;
        }
        else
        {
            a +=x;
        }

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

    }

}


/*
[ ( ^ _ ^ ) ]
*/
import java.io.*;
import java.util.*;

public class check {
    int INF = (int)1e9;
    long MOD = 1000000007;

    long go(long n, long m) {
        if(n>m) {
            long t = m;
            m = n;
            n = t;
        }
        long o = n*m;
        if(n<=3 && m<=3) {
            if(n==1 || m==1) return 0;
            if(n==2 && m==2) return 0;
            if(n==2 && m==3) return 4;
            if(n==3 && m==2) return 4;
            if(n==3 && m==3) return 8;
            return 0;
        }
        if(n==1) {
            m = m%6;
            if(m==4) m = 2;
            else if(m==5) m = 1;
            return o-m;
        } else if(n==2) {
            if(m==3 || m==7) m = 2;
            else m = 0;
            return o-m;
        }
        return o-o%2;
    }

    void solve(InputReader in, PrintWriter out) throws IOException {
        long n = in.nextInt();
        long m = in.nextInt();
        long rs = go(n, m);
        out.println(rs);
    }

    public static void main(String[] args) throws IOException {
        if(args.length>0 && args[0].equalsIgnoreCase("d")) {
            DEBUG_FLAG = true;
        }
        InputReader in = new InputReader();
        PrintWriter out = new PrintWriter(System.out);
        int t = 1;//in.nextInt();
        long start = System.nanoTime();
        while(t-- >0) {
            new check().solve(in, out);
        }
        long end = System.nanoTime();
        debug("\nTime: " + (end-start)/1e6 + " \n\n");
        out.close();
    }

    static boolean DEBUG_FLAG = false;
    static void debug(String s) {
        if(DEBUG_FLAG) System.out.print(s);
    }

    public static void show(Object... o) {
        System.out.println(Arrays.deepToString(o));
    }

    static class InputReader {
        static BufferedReader br;
        static StringTokenizer st;

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

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

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

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

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


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

public class C626 {
    public static void main(String[] args) throws IOException {
        ContestsScanner sc = new ContestsScanner();
        PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
        int two = sc.nextInt();
        int three = sc.nextInt();
        int hTwo = two * 2;
        int hThree = three * 6;
        if (hThree > 0) {
            hThree -= 3;
        }
        int lastSix = 0;

        int score = Integer.MAX_VALUE;
        while (hThree > 3 && hThree > hTwo && lastSix + 6 < hThree) {
            score = Math.min(score, Math.max(hThree, hTwo));
            if (lastSix + 6 <= hTwo) {
                hTwo += 2;
            }
            lastSix += 6;
            hThree -= 6;
        }
        score = Math.min(score, Math.max(lastSix, Math.max(hThree, hTwo)));
        out.println(score);
        out.close();
    }

    public static class ContestsScanner {

        private final BufferedReader br;
        private StringTokenizer tokenizer;

        public ContestsScanner() throws IOException {
            br = new BufferedReader(new InputStreamReader(System.in));
            tokenizer = new StringTokenizer(br.readLine());
        }

        String nextToken() {
            if (!tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

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


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

public class A {

	static String[] notes = {"C", "C#", "D", "D#", "E", "F", "F#", "G", "G#", "A", "B", "H" };

	public static void main(String[] agrs) {
		FastScanner sc = new FastScanner();
//		int yo = sc.nextInt();
//		while(yo-->0) {
//		}

		String s1 = sc.next();
		String s2 = sc.next();
		String s3 = sc.next();

		String[] arr = {s1,s2,s3};

		boolean vis[] = new boolean[3];

		String res = gen(arr, new ArrayList<String>(), vis,false);

//		if(res == null) {
//			System.out.println("strange");
//		}
//		else {
//			System.out.println(res);
//		}
		System.out.println(ans.equals("minor") || ans.equals("major") ? ans : "strange");

	}

	static String ans = "";
	static boolean is = false;
	static String gen(String[] arr, List<String> str, boolean[] vis, boolean is) {

//		System.out.println(str);
		if(is) return null;

		if(str.size() == 3) {
//			System.out.println(str);
			String str1 = check(str);
//			System.out.println(str1);
			if(str1.equals("major") || str1.equals("minor")) {
				is = true;
				ans = str1;
				return str1;
			}
			return null;
		}
		for(int i = 0; i < arr.length; i++) {
			if(vis[i] == false && !is) {
				vis[i] = true;
				str.add(arr[i]);
				gen(arr,str,vis,is);
				str.remove(str.size()-1);
				vis[i] = false;
			}
		}
		return null;
	}

	static String check(List<String> str) {

		int dist1 = getDistance(str.get(0), str.get(1));
		int dist2 = getDistance(str.get(1), str.get(2));
//		System.out.println(dist1 + " " + dist2);
		if(dist1 == 4 && dist2 == 3) {
			return "major";
		}
		if(dist1 == 3 && dist2 == 4) {
			return "minor";
		}

		return "";
	}

	static int getDistance(String s1, String s2) {
		int index1 = 0;
		int index2 = 0;
		for(int i = 0; i < notes.length; i++) {
			if(notes[i].equals(s1)) {
				index1 = i;
			}
			if(notes[i].equals(s2)) {
				index2 = i;
			}

		}

		if(index1 < index2) {
			return index2 - index1;
		}
		else {
			return (notes.length-index1) + Math.abs(index2);
		}

//		index2-index1 < 0 ?  Math.abs(index2-index1)*2 :
	}

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

	static int mod = 1000000007;

	static long pow(int a, int b) {
		if(b == 0) {
			return 1;
		}
		if(b == 1) {
			return a;
		}
		if(b%2 == 0) {

			long ans = pow(a,b/2);
			return ans*ans;
		}
		else {
			long ans = pow(a,(b-1)/2);
			return a * ans * ans;
		}

	}

	static boolean[] sieve(int n) {

		boolean isPrime[] = new boolean[n+1];
		for(int i = 2; i <= n; i++) {
			if(isPrime[i]) continue;
			for(int j = 2*i; j <= n; j+=i) {
				isPrime[j] = true;
			}
		}
		return isPrime;
	}

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

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

}


import java.io.*;
import java.security.cert.*;
public class Main {
    public static void main(String[] args)throws Exception {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		int a[]=Androiz.separator(br.readLine()," "),x=1;
		while(a[1]>=0){
			a[1]-=x;
			if (x==a[0])x=1;else x++;}
			if(x==1)x=a[0];else x--;
			System.out.println(a[1]+x);

	}
}
class Androiz{
	static int lengthArray=-1;

	static int[] separator(String s,String pr){
		int[] n;
		String[] stringArray;
		char[] charArray;
		if(pr==" "){
			stringArray=s.split(" ");
			n=new int[(s.length()+1)/2];
			for(int i=0;i<stringArray.length;i++)n[i]=Integer.parseInt(stringArray[i]);
			lengthArray=stringArray.length;
		}else if (pr==""){
			charArray=s.toCharArray();
			n=new int[s.length()];
			for(int i=0;i<s.length();i++)n[i]=Integer.parseInt(charArray[i]+"");
			lengthArray=s.length();
		}else n=new int[1];
		return n;
	}
}


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

public class Template implements Runnable {

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

    void init() throws FileNotFoundException {
        try {
            in = new BufferedReader(new FileReader("input.txt"));
            out = new PrintWriter("output.txt");
        } catch (Exception e) {
            in = new BufferedReader(new InputStreamReader(System.in));
            out = new PrintWriter(System.out);
        }
    }

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

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

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

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

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

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

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

    long timeBegin, timeEnd;

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

    long memoryTotal, memoryFree;

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

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

    int mod = (int) 1e9 + 7;

    int rev(int x, int n) {
        return n - x + 1;
    }

    void solve() throws IOException {
        int n = readInt();
        int a = readInt();
        int b = readInt();
        int k = readInt();

        if (a > b) {
            a = rev(a, n);
            b = rev(b, n);
        }

        long[] dp = new long[n + 1];
        dp[a] = 1;

        for (int it = 0; it < k; it++) {
            long[] next = new long[n + 1];
            long[] decrease = new long[n + 1];

            long sum = 0;
            for (int i = 1; i < b; i++) {
                int len = Math.abs(b - i) - 1;
                next[i] += sum;
                sum += dp[i];
                if (i - len > 0) decrease[i - len] += dp[i];
            }
            sum = 0;
            for (int i = b - 2; i > 0; i--) {
                next[i] += sum;
                sum += dp[i];
                sum -= decrease[i];
            }
            for (int i = 1; i <= n; i++) {
                dp[i] = next[i] % mod;
            }
        }

        long answer = 0;
        for (long d : dp)
            answer = (answer + d) % mod;
        out.println(answer);

    }
}


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

/**
 * User: chen
 */
public class DifferenceRow {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int[] num = new int[n];
        for (int i = 0; i < n; i++) {
            num[i] = in.nextInt();
        }
        Arrays.sort(num);
        System.out.print(num[n - 1] + " ");
        if (n > 2) {
            for (int i = 1; i < n - 1; i++) {
                System.out.print(num[i] + " ");
            }
        }
        System.out.print(num[0]);
    }
}


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

public class Smile {
	static Scanner in;
	static PrintWriter out;

	public static void main(String[] args) {
		in = new Scanner(System.in);
		out = new PrintWriter(System.out);
//		Map<Integer, Integer> a = new HashMap<Integer, Integer>();
		long n = in.nextInt();
		long m = in.nextInt();
		long k = n;
		int i = 0;
		while (k < m) {
//			a.put(k, i);
			i++;
			k *= n;
		}
		if (k == m) {
			out.println("YES");
			out.println(i);
		} else {
			out.println("NO");
		}

		out.close();
	}
}


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

public class Main {
    private static boolean oj = System.getProperty("ONLINE_JUDGE") != null;
    private static Reader in;
    private static PrintWriter out;
    ////////////////////////////////////////////////////////////////////////////////////////////////////
    private static int min(int... a){int min=a[0]; for(int i:a) min=Math.min(min, i); return min;}
    private static int max(int... a){int max=a[0]; for(int i:a) max=Math.max(max, i); return max;}
    private static long min(long... a){long min=a[0]; for(long i:a)min=Math.min(min, i); return min;}
    private static long max(long... a){long max=a[0]; for(long i:a)max=Math.max(max, i); return max;}
    private static String strm(String str, long m) {
        String ans="";
        while(m>0) {
            if(m%2==1) ans=ans.concat(str);
            str=str.concat(str); m>>=1;
        } return ans;
    }
    private static long mod(long a, long mod) {long res = a%mod; return res>=0 ? res : res+mod;}
    private static int mod(int a, int mod) {int res = a%mod; return res>=0 ? res : res+mod;}
    private static long modpow(long x, int n, int mod) {
        long res = 1;
        for (long p = x; n > 0; n >>= 1, p = mod((mod(p, mod)*mod(p, mod)),  mod)) {
            if ((n & 1) != 0) res = mod(mod(res, mod) * mod(p, mod), mod);
        }
        return res;
    }
    private static long gcd(long a, long b) {return b == 0 ? Math.abs(a) : gcd(b, a % b);}
    private static int gcd(int a, int b) {return b == 0 ? Math.abs(a) : gcd(b, a % b);}
    private static long gcd(long... a) {long gcd=a[0]; for(long x:a) gcd=gcd(gcd, x); return gcd;}
    private static int gcd(int... a) {int gcd=a[0]; for(int x:a) gcd=gcd(gcd, x); return gcd;}
    private static long lcm(long a, long b) {return Math.abs(a / gcd(a, b) * b);}
    private static class Pair {
        public int x, y;
        public Pair(int x, int y) {
            this.x = x;
            this.y = y;
        }
        @Override
        public boolean equals(Object obj) {
            if (obj == this) return true;
            if (!(obj instanceof Pair)) return false;
            Pair pair = (Pair)obj;
            return this.x == pair.x && this.y == pair.y;
        }

        @Override
        public int hashCode() {
            return (this.x+" "+this.y).hashCode();
        }
    }
    private static class Triplet {
        public int x, y, z;
        public Triplet(int x, int y, int z) {
            this.x = x;
            this.y = y;
            this.z = z;
        }
        @Override
        public boolean equals(Object obj) {
            if (obj == this) return true;
            if (!(obj instanceof Triplet)) return false;
            Triplet triplet = (Triplet)obj;
            return this.x == triplet.x && this.y == triplet.y && this.z == triplet.z;
        }

        @Override
        public int hashCode() {
            return (this.x+" "+this.y+" "+this.z).hashCode();
        }
    }
    ////////////////////////////////////////////////////////////////////////////////////////////////////
    static class Reader {
        private BufferedReader br;
        private StringTokenizer token;
        protected Reader(FileReader obj) {
            br = new BufferedReader(obj, 32768);
            token = null;
        }
        protected Reader() {
            br = new BufferedReader(new InputStreamReader(System.in), 32768);
            token = null;
        }
        protected String next() {
            while(token == null || !token.hasMoreTokens()) {
                try {
                    token = new StringTokenizer(br.readLine());
                } catch (Exception e) {e.printStackTrace();}
            } return token.nextToken();
        }
        protected String nextLine() {
            String str="";
            try {
                str = br.readLine();
            } catch (Exception e) {e.printStackTrace();}
            return str;
        }
        protected int nextInt() {return Integer.parseInt(next());}
        protected long nextLong() {return Long.parseLong(next());}
        protected double nextDouble() {return Double.parseDouble(next());}
        protected long[] nextLongArr(int n) {
            long[] arr = new long[n]; for(int i=0; i<n; i++) arr[i] = nextLong(); return arr;
        }
        protected int[] nextIntArr(int n) {
            int[] arr = new int[n]; for(int i=0; i<n; i++) arr[i] = nextInt(); return arr;
        }
    }
    public static final int mod = 1_000_000_007;
    private static void solve() throws Exception {
        int n = in.nextInt(), l = in.nextInt(), r = in.nextInt();
        long[] mod = new long[3];
        if (l == r) {
            if (l%3 == 0) mod = new long[]{1, 0, 0};
            else if (l%3 == 1) mod = new long[]{0, 1, 0};
            else mod = new long[]{0, 0, 1};
        }
        else {
        mod[0] = (r/3) - (long)ceil((double)(l)/3.0) + 1;
        mod[1] = ((r-1)/3) - (long)ceil((double)(l-1)/3.0) + 1;
        mod[2] = ((r-2)/3) - (long)ceil((double)(l-2)/3.0) + 1; }
        // out.println(Arrays.toString(mod));
        long[][] dp = new long[n+1][3];
        dp[1][0] = mod[0]; dp[1][1] = mod[1]; dp[1][2] = mod[2];
        for (int i=2; i<=n; i++) {
            dp[i][0] = mod(dp[i-1][0]*mod[0] + dp[i-1][1]*mod[2] + dp[i-1][2]*mod[1], 1_000_000_007);
            dp[i][1] = mod(dp[i-1][0]*mod[1] + dp[i-1][1]*mod[0] + dp[i-1][2]*mod[2], 1_000_000_007);
            dp[i][2] = mod(dp[i-1][0]*mod[2] + dp[i-1][1]*mod[1] + dp[i-1][2]*mod[0], 1_000_000_007);
        }
        out.printf("%d\n", dp[n][0]);
    }
    private static void run() throws Exception
    {
//        in = new Reader();
//        in = new Reader(new FileReader("input.txt"));
//        out = new PrintWriter(new FileWriter("output.txt"));
        in = oj ? new Reader() : new Reader(new FileReader("C:\\Users\\Suhaib\\Desktop\\input.txt"));
        out = new PrintWriter(System.out);
        long ti = System.currentTimeMillis();
        solve(); out.flush();
        if (!oj) System.out.println("\n"+(System.currentTimeMillis()-ti)+"ms");
    }
    public static void main(String[] args) throws Exception {run();}
}


import java.io.*;
import java.math.BigInteger;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Main
{
  public static void main(String[] args) throws Exception
   {
	   InputStream inputStream = System.in;
       //OutputStream outputStream = System.out;
       Reader s = new Reader(inputStream);
      // Scanner sc=new Scanner(System.in);
       //PrintWriter out=new PrintWriter(System.out);

       int p=s.nextInt();
       int y=s.nextInt();

       int max=Integer.MIN_VALUE;

       for(int i=y;i>p;i--)
       {
    	   int flag=1;
    	   for(int j=2;j*j<=y && j<=p;j++)
    	   {
    		   if(i%j==0) {flag=0;break;}
    	   }

    	   if(flag==1) {System.out.println(i); return;}
       }

      System.out.println("-1");
   }
}

class Reader
{
   final private int BUFFER_SIZE = 1 << 16;

   private DataInputStream din;
   private byte[] buffer;
   private int bufferPointer, bytesRead;

   public Reader(InputStream in)
   {
      din = new DataInputStream(in);
      buffer = new byte[BUFFER_SIZE];
      bufferPointer = bytesRead = 0;
   }

   public long nextLong() throws Exception
   {
      long ret = 0;
      byte c = read();
      while (c <= ' ') c = read();
      boolean neg = c == '-';
      if (neg) c = read();
      do
      {
         ret = ret * 10 + c - '0';
         c = read();
      } while (c > ' ');
      if (neg) return -ret;
      return ret;
   }

   //reads in the next string
   public String next() throws Exception
   {
      StringBuilder ret =  new StringBuilder();
      byte c = read();
      while (c <= ' ') c = read();
      do
      {
         ret = ret.append((char)c);
         c = read();
      } while (c > ' ');
      return ret.toString();
   }

   public int nextInt() throws Exception
   {
      int ret = 0;
      byte c = read();
      while (c <= ' ') c = read();
      boolean neg = c == '-';
      if (neg) c = read();
      do
      {
         ret = ret * 10 + c - '0';
         c = read();
      } while (c > ' ');
      if (neg) return -ret;
      return ret;
   }

   private void fillBuffer() throws Exception
   {
      bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);
      if (bytesRead == -1) buffer[0] = -1;
   }

   private byte read() throws Exception
   {
      if (bufferPointer == bytesRead) fillBuffer();
      return buffer[bufferPointer++];
   }
}


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

public class CF1{
    public static void main(String[] args) {
        FastScanner sc=new FastScanner();
        int T=sc.nextInt();
//        int T=1;
        for (int tt=0; tt<T; tt++){
            int n = sc.nextInt();
            n=(int)power2(2,n);
            System.out.println(n-1);
        }
    }
    static long factorial (int x){
        if (x==0) return 1;
        long ans =x;
        for (int i=x-1; i>=1; i--){
            ans*=i;
//            ans%=mod;
        }
        return ans;
    }
    static int mod =1073741825;
    static long power2 (long a, long b){
        long res=1;
        while (b>0){
            if ((b&1)== 1){
                res= (res * a % mod)%mod;
            }
            a=(a%mod * a%mod)%mod;
            b=b>>1;
        }
        return res;
    }

    boolean[] sieveOfEratosthenes(int n)
    {

        boolean prime[] = new boolean[n+1];
        for(int i=0;i<=n;i++)
            prime[i] = true;

        for(int p = 2; p*p <=n; p++)
        {
            if(prime[p] == true)
            {
                for(int i = p*p; i <= n; i += p)
                    prime[i] = false;
            }
        }
        return prime;
    }
    static void sort(int[] a) {
        ArrayList<Integer> l=new ArrayList<>();
        for (int i:a) l.add(i);
        Collections.sort(l);
        for (int i=0; i<a.length; i++) a[i]=l.get(i);
    }
    static void sortLong(long[] a) {
        ArrayList<Long> l=new ArrayList<>();
        for (long i:a) l.add(i);
        Collections.sort(l);
        for (int i=0; i<a.length; i++) a[i]=l.get(i);
    }
    static long gcd (long n, long m){
        if (m==0) return n;
        else return gcd(m, n%m);
    }

    static class Pair implements Comparable<Pair>{
        int x,y;
        public Pair(int x, int y){
            this.x = x;
            this.y = y;
        }
        public int compareTo(Pair o){
            return this.x-o.x;
        }
        // this.x-o.x is ascending
    }
    static class FastScanner {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st=new StringTokenizer("");
        String next() {
            while (!st.hasMoreTokens())
                try {
                    st=new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            return st.nextToken();
        }

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


import java.util.Scanner;

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

		Scanner in = new Scanner(System.in);

		String s = in.nextLine();

		s = s.toLowerCase();

		char t = ' ';

		for (int i = s.length() - 1; i >= 0; i--) {
			if (s.charAt(i) >= 'a' && s.charAt(i) <= 'z') {
				t = s.charAt(i);
				break;
			}
		}

		if (t == 'a' || t == 'e' || t == 'i' || t == 'o' || t == 'u'
				|| t == 'y')
			System.out.println("YES");
		else
			System.out.println("NO");

	}
}


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

/**
 *
 * @Har_Har_Mahadev
 */

/**
 * Main , Solution , Remove Public
 */
public class D {

	public static void process() throws IOException {
		int n = sc.nextInt();
		long dp[] = new long[n+1];
		for(int i = 2; i<=n; i++) {
			for(int j = i; j<=n; j+=i)dp[j]++;
		}
		dp[0] = 1;
		long sum = 1;
		for(int i=1; i<=n; i++) {
			dp[i] = (dp[i] + sum)%MM;
			sum = (sum+dp[i])%MM;
		}
		println(dp[n]);

	}

	//=============================================================================
	//--------------------------The End---------------------------------
	//=============================================================================
	private static long INF = 2000000000000000000L, M = 1000000007, MM = 998244353;
	private static int N = 1_000_005;

	private static void google(int tt) {
		System.out.print("Case #" + (tt) + ": ");
	}

	static FastScanner sc;
	static PrintWriter out;

	public static void main(String[] args) throws IOException {
		boolean oj = true;
		if (oj) {
			sc = new FastScanner();
			out = new PrintWriter(System.out);
		} else {
			sc = new FastScanner(100);
			out = new PrintWriter("output.txt");
		}
		int t = 1;
//		t = sc.nextInt();
		int TTT = 1;
		while (t-- > 0) {
			//			google(TTT++);
			process();
		}
		out.flush();
		out.close();
	}

	static class Pair implements Comparable<Pair> {
		int x, y;

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

		@Override
		public int compareTo(Pair o) {
			return Integer.compare(this.x, o.x);
		}

		//		 @Override
		//		    public boolean equals(Object o) {
		//		        if (this == o) return true;
		//		        if (!(o instanceof Pair)) return false;
		//		        Pair key = (Pair) o;
		//		        return x == key.x && y == key.y;
		//		    }
		//
		//		    @Override
		//		    public int hashCode() {
		//		        int result = x;
		//		        result = 31 * result + y;
		//		        return result;
		//		    }
	}

	/////////////////////////////////////////////////////////////////////////////////////////////////////////

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

	static void println() {
		out.println();
	}

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

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

	static int ceil(int x, int y) {
		return (x % y == 0 ? x / y : (x / y + 1));
	}

	static long ceil(long x, long y) {
		return (x % y == 0 ? x / y : (x / y + 1));
	}

	static int max(int x, int y) {
		return Math.max(x, y);
	}

	static int min(int x, int y) {
		return Math.min(x, y);
	}

	static int abs(int x) {
		return Math.abs(x);
	}

	static long abs(long x) {
		return Math.abs(x);
	}

	static long sqrt(long z) {
		long sqz = (long) Math.sqrt(z);
		while (sqz * 1L * sqz < z) {
			sqz++;
		}
		while (sqz * 1L * sqz > z) {
			sqz--;
		}
		return sqz;
	}

	static int log2(int N) {
		int result = (int) (Math.log(N) / Math.log(2));
		return result;
	}

	static long max(long x, long y) {
		return Math.max(x, y);
	}

	static long min(long x, long y) {
		return Math.min(x, y);
	}

	public static int gcd(int a, int b) {
		BigInteger b1 = BigInteger.valueOf(a);
		BigInteger b2 = BigInteger.valueOf(b);
		BigInteger gcd = b1.gcd(b2);
		return gcd.intValue();
	}

	public static long gcd(long a, long b) {
		BigInteger b1 = BigInteger.valueOf(a);
		BigInteger b2 = BigInteger.valueOf(b);
		BigInteger gcd = b1.gcd(b2);
		return gcd.longValue();
	}

	public static long lcm(long a, long b) {
		return (a * b) / gcd(a, b);
	}

	public static int lcm(int a, int b) {
		return (a * b) / gcd(a, b);
	}

	public static int lower_bound(int[] arr, int x) {
		int low = 0, high = arr.length, mid = -1;

		while (low < high) {
			mid = (low + high) / 2;

			if (arr[mid] >= x)
				high = mid;
			else
				low = mid + 1;
		}

		return low;
	}

	public static int upper_bound(int[] arr, int x) {
		int low = 0, high = arr.length, mid = -1;

		while (low < high) {
			mid = (low + high) / 2;

			if (arr[mid] > x)
				high = mid;
			else
				low = mid + 1;
		}

		return low;
	}

	/////////////////////////////////////////////////////////////////////////////////////////////////////////

	static class FastScanner {
		BufferedReader br;
		StringTokenizer st;

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

		FastScanner(int a) throws FileNotFoundException {
			br = new BufferedReader(new FileReader("input.txt"));
		}

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

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

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

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

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

		int[] readArray(int n) throws IOException {
			int[] A = new int[n];
			for (int i = 0; i != n; i++) {
				A[i] = sc.nextInt();
			}
			return A;
		}

		long[] readArrayLong(int n) throws IOException {
			long[] A = new long[n];
			for (int i = 0; i != n; i++) {
				A[i] = sc.nextLong();
			}
			return A;
		}
	}

	static void ruffleSort(int[] a) {
		Random get = new Random();
		for (int i = 0; i < a.length; i++) {
			int r = get.nextInt(a.length);
			int temp = a[i];
			a[i] = a[r];
			a[r] = temp;
		}
		Arrays.sort(a);
	}

	static void ruffleSort(long[] a) {
		Random get = new Random();
		for (int i = 0; i < a.length; i++) {
			int r = get.nextInt(a.length);
			long temp = a[i];
			a[i] = a[r];
			a[r] = temp;
		}
		Arrays.sort(a);
	}
}


import java.io.*;
import java.util.*;
import java.util.logging.Level;
import java.util.logging.Logger;
import static java.lang.System.*;

public class NewClass{
    public static BufferedReader br;
    static FastReader s = new FastReader();
    public static BufferedWriter bor = new BufferedWriter(new OutputStreamWriter(out));
    public static void main(String[] args) throws IOException{
        //int t = s.nextInt();
        //while(t-->0){
                solve();
        //}
    }

    static void solve() throws IOException{
            long k2 = s.nextLong(),k3 = s.nextLong(),k5 = s.nextLong(),k6 = s.nextLong();
            long answer = Math.min(k2,Math.min(k5, k6))*256 + Math.min(k2 - Math.min(k2,Math.min(k5, k6)),k3) * 32;
            println(answer);
    }

    static class FastReader{
        private 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 ex) {
                    Logger.getLogger(NewClass.class.getName()).log(Level.SEVERE, null, ex);
                }
            }
            return st.nextToken();
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException ex) {
                Logger.getLogger(NewClass.class.getName()).log(Level.SEVERE, null, ex);
            }
            return str;
        }

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

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

        float nextFloat(){
            return Float.parseFloat(next());
        }

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

    static void println(){
        out.println();
    }

    static void print(){
        out.print("");
    }

    static void println(String flouu){
        out.println(flouu);
    }

    static void println(long flouu){
        out.println(flouu);
    }

    static void println(double flouu){
        out.println(flouu);
    }
    static void println(float flouu){
       out.println(flouu);
    }

    static void println(char flouu){
        out.println(flouu);
    }

    static void print(char flouu){
        out.print(flouu);
    }

    static void print(String flouu){
        out.print(flouu);
    }

    static void print(long flouu){
        out.print(flouu);
    }

    static void print(double flouu){
        out.print(flouu);
    }
    static void print(float flouu){
       out.print(flouu);
    }

}


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

public class RookBishopAndKing {

    void run() throws Exception {
        BufferedReader bfd = new BufferedReader(
                new InputStreamReader(System.in));
        StringTokenizer tk = new StringTokenizer(bfd.readLine());
        int r1 = Integer.parseInt(tk.nextToken());
        int c1 = Integer.parseInt(tk.nextToken());
        int r2 = Integer.parseInt(tk.nextToken());
        int c2 = Integer.parseInt(tk.nextToken());

        int r = 0, b = 0, k = 0;
        r += (r1 == r2 ? 0 : 1);
        r += (c1 == c2 ? 0 : 1);

        if ((r1 + c1)%2 == (r2 + c2)%2) {
            if (Math.abs(r1 - r2) == Math.abs(c1 - c2))
                b = 1;
            else
                b = 2;
        }

        int dx = Math.abs(r1 - r2);
        int dy = Math.abs(c1 - c2);
        k =  dx + dy - Math.min(dx, dy);

        System.out.println(r + " " + b + " " + k);
    }

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

}


import java.util.*;

public class codeforces {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int min= a>b ? b : a;
        if (min%2==0){System.out.print("Malvika");}else{System.out.print("Akshat");}
    }
}


import java.util.Scanner;

public class buttons {
    public static void main(String args[])
    {
        Scanner s = new Scanner(System.in);
        System.out.println(worst_times(s.nextInt()));
    }
    private static int worst_times(int n)
    {
        int total = 0;
        for(int i=1;i<n;i++)
        {
            total+=(n-i)*i+1;
        }
        return total+1;
    }
}


import java.util.*;

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

		int n = input.nextInt();

		String s = "";

		for (int i = 0; i < 500; i++) {
			s += i;

		}
		System.out.println(s.charAt(n));

	}
}


import java.util.Scanner;

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

		Scanner in = new Scanner(System.in);
		int n = in.nextInt(), i, j;
		String t = in.next(), s = "";
		in.close();

		for (i = 2; i <= n; i++)
			if (n % i == 0) {
				for (j = i - 1; j >= 0; j--)
					s += t.charAt(j);

				s += t.substring(i);
				t = s;
				s = "";
			}
		System.out.println(t);
	}
}


import java.util.*;

public class Main {

	public static void main(String[] args) {

		Scanner in = new Scanner(System.in);
		int N = in.nextInt();
		String str = in.next();
		System.out.println(getAns(str, N));
		in.close();
	}

	public static int getAns(String str, int N) {
		int ans = 0;
		StringBuilder sb = new StringBuilder(str);
		for (int i = 25; i >= 0; i--) {
			char ch = (char) (97 + i);
			for (int j = 0; j < sb.length(); j++) {
				if (sb.length() == 1) {
					break;
				}
				char ch1 = sb.charAt(j);
				if (ch != ch1) {
					continue;
				}
//				System.out.println(j);
				if (j == 0 && ((int) ch - 1 == (int) sb.charAt(j + 1))) {
					//System.out.println("leftMost " + j);
					sb.deleteCharAt(j);
					ans++;
					j -= 1;
					continue;
				} else if (j == sb.length() - 1 && ((int) ch - 1 == (int) sb.charAt(j - 1))) {
					//System.out.println("rightMost " + j);
					sb.deleteCharAt(j);
					ans++;
					j -= 1;
					continue;
				} else if ((j < sb.length() - 1 && (int) ch - 1 == (int) sb.charAt(j + 1))
						|| (j > 0 && (int) ch - 1 == (int) sb.charAt(j - 1))) {
					//System.out.println("middle " + j);
					sb.deleteCharAt(j);
					ans++;
					j -= 2;
					//System.out.println("middle " + j + " " + sb.toString() + " " + sb.length());
					continue;
				}
				//System.out.println(sb.toString());
			}
		}
		return ans;
	}

}


import java.util.*;

/*
_Пересдача
*/
public class A991 {
    public static void main(String...args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int n = sc.nextInt();
        System.out.println(method(a, b, c, n));
    }
    public static int method(int a, int b, int c, int n){
        int answer = n - (a+b-c);
        if(a+b-c >= n||a<c||b<c)return -1;

        if(answer != 0)return answer;
        return -1;
    }
}


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


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

		int n = in.nextInt();
		int m = in.nextInt();
		int a = in.nextInt();
		int b = in.nextInt();

		int aa = n * a;
		int bb = (n / m) * b;
		if(n % m != 0)
			bb += b;

		int tmp = (n / m) * b;
		tmp += (n % m) * a;

		int min = Math.min(aa, Math.min(bb, tmp));

		System.out.println(min);

	}

}


import java.util.*;
public class Main
{

	public static void main(String[] args) {
	    Scanner sc=new Scanner(System.in);
	    int n=sc.nextInt();
	    int a[]=new int[n];
	    int b[]=new int[n];
	    int aa=0,bb=0;
	   for(int i=0;i<n;i++)
	   {
	       a[i]=sc.nextInt();
	   }

	   for(int i=0;i<n;i++)
	   {
	       b[i]=sc.nextInt();
	   }
	   for(int i=0;i<n;i++)
	   {
	      if(a[i]==1 && a[i]!=b[i])
	      {
	          aa++;
	      }
	      if(b[i]==1 && a[i]!=b[i])
	      {
	          bb++;
	      }
	   }
	   if(aa==0){
	       System.out.println(-1);

	   }
	   else{
	   int ans=bb/aa;
	   System.out.println(ans+1);}

	}
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Random;
import java.util.Set;
import java.util.StringTokenizer;

public class Main {

  static BufferedReader in;
  static PrintWriter out;
  static StringTokenizer tok;
  static void solve() throws Exception {

	  int n = nextInt();
	  int l = nextInt();
	  int r = nextInt();
	  int x = nextInt();
	  int[] values = readIntArray(n);

	  int res = 0;
	  for(int i = 0 ; i < (int)Math.pow(2, n); i++) {
		  int count = 0;
		  int max = Integer.MIN_VALUE;
		  int min = Integer.MAX_VALUE;
		  for(int j = 0 ; j < values.length ; j++) {
			  if( ((1<<j) & i) > 0) {

				  count += values[j];
				  max = Math.max(max, values[j]);
				  min = Math.min(min, values[j]);
			  }
		  }
		  if( count >= l && count <=r && (max - min) >= x) {
			  res++;
		  }
	  }
	  System.out.println(res);
  }

  static int remove(String s) {
	  if(s.length() ==0)
		  return 0;
	  boolean found = false;
	  int index = 0;
	  for(int i = 0 ; i < s.length()-1 ; i++) {
		  if(s.charAt(i) =='0' && s.charAt(i+1) =='1') {
			  found = true;
		  }
		  if(s.charAt(i) =='1' && s.charAt(i+1) =='0') {
			  found = true;
		  }
		  if(found) {
			  index = i;
			  break;
		  }
	  }
	  if(!found)
		  return s.length();

	  if(found && s.length() == 2)
		  return 0;
	  return remove(s.substring(0, index)+s.substring(index+2, s.length()));

  }

  static void taste(int t[], int c[], int i, int j) {

  }

  static String findDist(int r1, int c1, int n, int m, String []cave, int r2, int c2, String [][] mem) {

	  if(r1 >=n || c1>=m || r1 <0 || c1 <0)
		  return "";

	  if(cave[n].charAt(m) == 'X')
		  return "";

	  String value = "";

	  if(r1 == r2 && c1 == c2) {
		  value = "YES";
		  return value;

	  }

	  if(cave[n].charAt(m) == '.')
		  return ".";

	  String value1  = findDist(r1+1, c1, n,m, cave, r2, c2, mem);
	  String value2  = findDist(r1, c1+1, n,m, cave, r2, c2, mem);
	  String value3  = findDist(r1-1, c1, n,m, cave, r2, c2, mem);
	  String value4  = findDist(r1, c1-1, n,m, cave, r2, c2, mem);

	  return value;
  }

  public static void main(String args[]) {
    try {
      in = new BufferedReader(new InputStreamReader(System.in));
      out = new PrintWriter(new OutputStreamWriter(System.out));
      solve();
      in.close();
      out.close();
    } catch (Throwable e) {
      e.printStackTrace();
      System.exit(1);
    }
  }

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

  static int[] nextIntArray(int len, int start) throws IOException {
    int[] a = new int[len];
    for (int i = start; i < len; i++)
      a[i] = nextInt();
    return a;
  }

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

  static long[] nextLongArray(int len, int start) throws IOException {
    long[] a = new long[len];
    for (int i = start; i < len; i++)
      a[i] = nextLong();
    return a;
  }

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

  static double[] nextDoubleArray(int len, int start) throws IOException {
    double[] a = new double[len];
    for (int i = start; i < len; i++)
      a[i] = nextDouble();
    return a;
  }

  static BigInteger nextBigInteger() throws IOException {
    return new BigInteger(next());
  }

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

  static String nextLine() throws IOException {
    tok = new StringTokenizer("");
    return in.readLine();
  }

  static void shuffleArray(long[] array) {
    Random random = new Random();
    for (int i = array.length - 1; i > 0; i--) {
      int index = random.nextInt(i + 1);
      long temp = array[index];
      array[index] = array[i];
      array[i] = temp;
    }
  }

  static boolean hasNext() throws IOException {
    while (tok == null || !tok.hasMoreTokens()) {
      String s = in.readLine();
      if (s == null) {
        return false;
      }
      tok = new StringTokenizer(s);
    }
    return true;
  }

  public static int[] readIntArray(int size) throws IOException {
      int[] result = new int[(int) size];
      for (int i = 0; i < size; i++) {
          result[(int) i] = (int)nextInt();
      }
      return result;
  }

}


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

public class restoringPainting {
public static void main(String[] args) throws IOException {
	BufferedReader bf=new BufferedReader(new InputStreamReader(System.in));
	String x=bf.readLine();
	String[] y=x.split(" ");
	int n=Integer.parseInt(y[0]);
	int a=Integer.parseInt(y[1]);
	int b=Integer.parseInt(y[2]);
	int c=Integer.parseInt(y[3]);
	int d=Integer.parseInt(y[4]);
	int z3=1;
	int z1=1;
	int z2;
	int z4;
	int z5;
	long counter=0;
	int counter2=1;
	if(n==1)
	{
		System.out.println(1);
		return;
	}
	for(int i=1;i<=n;i++)
	{
		z1=i;
		z5=z1+a-d;
		z2=z1+b-c;
		z4=b+a+z1-d-c;
		if((z5>0&&z2>0&&(z4>0))&&(z5<=n&&(z2<=n)&&(z4<=n)))
		{
			counter++;
		}
	}
	counter*=n;
	System.out.println(counter);
}
}


import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Solution{

    ///////////////////////////////////////////////////////////////////////////
    static class FastScanner{
        BufferedReader s;
        StringTokenizer st;

        public FastScanner(InputStream InputStream){
            st = new StringTokenizer("");
            s = new BufferedReader(new InputStreamReader(InputStream));
        }

        public FastScanner(File f) throws FileNotFoundException{
            st = new StringTokenizer("");
            s = new BufferedReader (new FileReader(f));
        }

        public int nextInt() throws IOException{
            if(st.hasMoreTokens())
                return Integer.parseInt(st.nextToken());
            else{
                st = new StringTokenizer(s.readLine());
                return nextInt();
            }
        }

        public BigInteger big() throws IOException{
            if(st.hasMoreTokens())
                return new BigInteger(st.nextToken());
            else{
                st = new StringTokenizer(s.readLine());
                return big();
            }
        }

        public double nextDouble() throws IOException{
            if(st.hasMoreTokens())
                return Double.parseDouble(st.nextToken());
            else{
                st = new StringTokenizer(s.readLine());
                return nextDouble();
            }
        }

        public long nextLong() throws IOException{
            if(st.hasMoreTokens())
                return Long.parseLong(st.nextToken());
            else{
                st = new StringTokenizer(s.readLine());
                return nextLong();
            }
        }

        public String nextString() throws IOException{
            if(st.hasMoreTokens())
                return st.nextToken();
            else{
                st = new StringTokenizer(s.readLine());
                return nextString();
            }

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

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

    }

    ////////////////////////////////////////////////////////////////////
    //      Number Theory

    long pow(long a,long b,long mod){
        long x = 1; long y = a;
        while(b > 0){
            if(b % 2 == 1){
                x = (x*y);
                x %= mod;
            }
            y = (y*y);
            y %= mod;
            b /= 2;
        }
        return x;
    }

    int divisor(long x,long[] a){
        long limit = x;
        int numberOfDivisors = 0;

        for (int i=1; i < limit; ++i) {
            if (x % i == 0) {
                limit = x / i;
                if (limit != i) {
                    numberOfDivisors++;
                }
                numberOfDivisors++;
            }
        }
        return numberOfDivisors;
    }

    void findSubsets(int array[]){
        long numOfSubsets = 1 << array.length;
        for(int i = 0; i < numOfSubsets; i++){
            @SuppressWarnings("unused")
            int pos = array.length - 1;
            int bitmask = i;
            while(bitmask > 0){
                if((bitmask & 1) == 1)
//                    ww.print(array[pos]+" ");
                bitmask >>= 1;
                pos--;
            }
//            ww.println();
        }
    }

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

    public static int lcm(int a,int b, int c){
        return lcm(lcm(a,b),c);
    }

    public static int lcm(int a, int b){
        return (int) (a*b/gcd(a,b));
    }

    public static long invl(long a, long mod) {
        long b = mod;
        long p = 1, q = 0;
        while (b > 0) {
            long c = a / b;
            long d;
            d = a;
            a = b;
            b = d % b;
            d = p;
            p = q;
            q = d - c * q;
        }
        return p < 0 ? p + mod : p;
    }

    ////////////////////////////////////////////////////////////////////

//    FastScanner s = new FastScanner(new File("input.txt"));
//    PrintWriter ww = new PrintWriter(new FileWriter("output.txt"));
    static InputStream inputStream = System.in;
    static FastScanner s = new FastScanner(inputStream);
    static OutputStream outputStream = System.out;
    static PrintWriter ww = new PrintWriter(new OutputStreamWriter(outputStream));
//      private static Scanner s = new Scanner(System.in);
    @SuppressWarnings("unused")
    private static int[][] states = { {-1,0} , {1,0} , {0,-1} , {0,1} };

    ////////////////////////////////////////////////////////////////////

    public static void main(String[] args) throws IOException{
        new Solution().solve();
        s.close();
        ww.close();
    }

    ////////////////////////////////////////////////////////////////////

    void solve() throws IOException{

        long a[] = new long [3];
        for (int i = 0; i < 3; i++)
            a[i] = s.nextInt();

        Arrays.sort(a);
        if(2 * (a[0] + a[1]) <= a[2])
            a[2] = 2 * (a[0] + a[1]);

        ww.println((a[0]+a[1]+a[2])/3);

    }
}


import java.util.Scanner;

public class CF509A {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		n = (n - 1) * 2;
		long res = 1;
		for(int i = 0; i < n / 2; i++) res *= (n/2 + i + 1);
		for(int i = 0; i < n / 2; i++) res /= (i + 1);
		System.out.println(res);
	}
}


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

public class CrocElB
{
    public static StringTokenizer st;
    public static void nextLine(BufferedReader br) throws IOException
    {
        st = new StringTokenizer(br.readLine());
    }

    public static String next()
    {
        return st.nextToken();
    }

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

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

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

    public static void main(String[] args) throws IOException
    {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        nextLine(br);
        long n = nextInt();
        long k = nextInt();
        if (k >= n/2)
        {
            long ans = (n * (n-1)) / 2;
            System.out.println(ans);
            return;
        }
        long rem = n;
        long sum = 0;
        for (int i = 0; i < k; i++)
        {
            rem -= 2;
            sum += 2 * rem + 1;
        }
        System.out.println(sum);
    }

}


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

//solution classes here

public class Code {

    //main solution here

    static Scanner sc = new Scanner(System.in);
    static PrintWriter out = new PrintWriter(System.out);
    static long mod = 998244353;
    static long MOD = (long)1e9+7;
    //static ArrayList<Integer> list[] = new ArrayList[(int)1e6+1];
    //static int color[] = new int[(int)1e6+1];
    //static int visit[] = new int[(int)1e5+1];
    //static Deque<Integer> q = new ArrayDeque<>();
    public static void main(String[] args) throws IOException {
        int n = sc.nextInt();
        if(n%2==0) {
            out.println("white");
            out.print("1 2");
        }
        else {
            out.print("black");
        }

        out.flush();
        out.close();
    }
    //solution functions here

    static class Scanner {
        StringTokenizer st;
        BufferedReader br;

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

        public Scanner(FileReader fileReader) {
            br = new BufferedReader(fileReader);
        }

        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 boolean ready() throws IOException {
            return br.ready();
        }
    }
}

/* *****************************************************************************************************************************
 * I'M NOT IN DANGER, I'M THE DANGER!!!
 * *****************************************************************************************************************************
 */


import java.util.Scanner;

public class A146 {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int t = sc.nextInt();
		String s = sc.next();
		int s1 = 0, s2 = 0;
		if (luck(s)) {
			for (int i = 0; i < t / 2; i++)
				s1 += Integer.valueOf(String.valueOf(s.charAt(i)));
			for (int i = t / 2; i < s.length(); i++)
				s2 += Integer.valueOf(String.valueOf(s.charAt(i)));
			if (s1 == s2)
				System.out.println("YES");
			else
				System.out.println("NO");
		} else
			System.out.println("NO");
	}

	public static boolean luck(String s) {
		if (s.contains("0") || s.contains("1") || s.contains("2")
				|| s.contains("3") || s.contains("5") || s.contains("6")
				|| s.contains("8") || s.contains("9"))
			return false;
		else
			return true;
	}

}


import java.util.*;

/**
 *
 * @author Lenovo
 */
public class JavaApplication2 {

    public static void main(String[] args) {

        Scanner in = new Scanner(System.in);
       String ar[]=new String[4];
       for(int i=0;i<4;i++){ar[i]=in.next();}
       int y=0;int z=0;boolean fi=false;
       int s=0;
       for(int i=0;i<3;i++){y=0;
       for(int u=0;u<3;u++){y=0;z=0;
           if(ar[i].charAt(u)=='#'){y++;}
           else if(ar[i].charAt(u)=='.') z++;
       if(ar[i+1].charAt(u)=='#'){y++;}
       else if(ar[i+1].charAt(u)=='.') z++;
       if(ar[i].charAt(u+1)=='#'){y++;}
           else if(ar[i].charAt(u+1)=='.') z++;
       if(ar[i+1].charAt(u+1)=='#'){y++;}
       else if(ar[i+1].charAt(u+1)=='.') z++;
       if((y==3||y==4)||(z==3||z==4)){fi=true;break;}

       }
       if(fi==true)break;
       }
        if(fi==true){System.out.println("YES");}
        else {System.out.println("NO");}

    }

    }


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

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

    static class TaskA {
        public void solve(int testNumber, Reader in, PrintWriter out) {
            int n = in.ni();
            PairInt[] points = new PairInt[n];
            for (int i = 0; i < n; i++) {
                points[i] = new PairInt(in.ni(), in.ni());
            }
            if (n == 1) {
                out.println(-1);
            } else if (n == 2) {
                if (points[0].x == points[1].x || points[0].y == points[1].y) {
                    out.println(-1);
                } else {
                    int diffX = Math.abs(points[0].x - points[1].x);
                    int diffY = Math.abs(points[0].y - points[1].y);
                    out.println(diffX * diffY);
                }
            } else {
                for (int i = 0; i < n; i++) {
                    for (int j = i + 1; j < n; j++) {
                        if (points[i].x != points[j].x && points[i].y != points[j].y) {
                            int diffX = Math.abs(points[j].x - points[i].x);
                            int diffY = Math.abs(points[j].y - points[i].y);
                            out.println(diffX * diffY);
                            return;
                        }
                    }
                }
            }
        }

    }

    static class Reader {
        private BufferedReader in;
        private StringTokenizer st = new StringTokenizer("");
        private String delim = " ";

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

        public String next() {
            if (!st.hasMoreTokens()) {
                st = new StringTokenizer(rl());
            }
            return st.nextToken(delim);
        }

        public String rl() {
            try {
                return in.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }

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

    }

    static class PairInt {
        public int x;
        public int y;

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

        public boolean equals(Object obj) {
            PairInt pairInt = (PairInt) obj;
            return pairInt.x == x && pairInt.y == y;
        }

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

        public PairInt clone() {
            return new PairInt(x, y);
        }

    }
}


import java.util.Scanner;
public class fillingShapesA{
    public static void main(String[] args) {
        Scanner sc= new Scanner(System.in);
        int n = sc.nextInt();
        sc.close();
        if(n<2 || n%2==1){
            System.out.println(0);
        }
        else{
            System.out.println((int)Math.sqrt(Math.pow(2, n)));
        }
    }
}


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

/*CODE BY SHIKHAR TYAGI*/

public class B {

    public static final int MOD = 1000000007;

    public static void main(String args[]) {
        FastScanner scn = new FastScanner();
        int t = 1;
        while (t-- > 0) {
            long n = scn.nextInt();
            long m = scn.nextInt();
            long ans = (((power((long)2, m, MOD) % MOD) - (1 % MOD)) + MOD) % MOD;
            ans = power(ans, n, MOD)%MOD;
            System.out.println(ans);
        }
    }

    static long power(long x, long y, int p) {

        // Initialize result
        long res = 1;

        // Update x if it is more than or
        // equal to p
        x = x % p;

        while (y > 0) {

            // If y is odd, multiply x
            // with result
            if (y % 2 == 1)
                res = (res * x) % p;

            // y must be even now
            y = y / 2; // y = y/2
            x = (x * x) % p;
        }

        return res;
    }

    static int exponentMod(int A, int B, int C) {

        // Base cases
        if (A == 0)
            return 0;
        if (B == 0)
            return 1;

        // If B is even
        long y;
        if (B % 2 == 0) {
            y = exponentMod(A, B / 2, C);
            y = (y * y) % C;
        }

        // If B is odd
        else {
            y = A % C;
            y = (y * exponentMod(A, B - 1, C) % C) % C;
        }

        return (int) ((y + C) % C);
    }

    public static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

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

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

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

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

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

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

    public static int bin(int b[], long target) {
        int l = 0;
        int h = b.length - 1;
        int pos = -1;
        while (l <= h) {
            int m = l + (h - l) / 2;
            if (b[m] <= target) {
                if (b[m] == target) {
                    return m;
                }
                l = m + 1;
            } else {
                pos = m;
                h = m - 1;
            }
        }
        return pos;
    }
}


import java.util.*;
import java.io.*;
import java.lang.*;
public class Codeforces{
    BufferedReader br =new BufferedReader(new InputStreamReader(System.in));
    PrintWriter out =new PrintWriter(System.out);
    StringTokenizer st =new StringTokenizer("");
    String next(){
        if(!st.hasMoreTokens()){
            try{
                st=new StringTokenizer(br.readLine());
            }
            catch(Exception e){

            }
        }
        return st.nextToken();
    }
    int nextInt(){
        return Integer.parseInt(next());
    }
    public static void main(String[] args) {
        new Codeforces().solve();
    }
    void solve(){
        List<List<Integer>> arr=new ArrayList<>();
        for(int i=0;i<=5;i++) arr.add(new ArrayList<>());
        int m=nextInt();
        for(int i=0;i<m;i++){
            int a=nextInt(),b=nextInt();
            arr.get(a).add(b);
            arr.get(b).add(a);
        }
        boolean flag=false;
        // out.println(arr);
        for(int i=1;i<=5;i++){
            if(arr.get(i).size()<=1 || arr.get(i).size()>=3){
                flag=true;
            }
        }
        if(flag){
            out.println("WIN");
        }
        else{
            out.println("FAIL");
        }
        out.close();
    }
}


import java.util.*;

public class cfinf {

    static boolean testFing(int a,int b)
    {
        return (b>=(a-1) && b<=2*(a+1));
    }

    public static void main(String[] argc)
    {
        Scanner in = new Scanner(System.in);
        int[] a = new int[2];
        int[] b = new int[2];
        for(int i=0;i<2;i++)
            a[i] = in.nextInt();
        for(int i=0;i<2;i++)
            b[i] = in.nextInt();
        if (testFing(a[0],b[1]) || testFing(a[1],b[0]))
            System.out.print("YES");
        else
            System.out.print("NO");
    }
}


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

public class Main {

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

    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    String[] nm = br.readLine().split(" ");
    int n = Integer.parseInt(nm[0]);
    int m = Integer.parseInt(nm[1]);

    PriorityQueue<Perm> pq = new PriorityQueue<Perm>(1, Perm.cmp);
    List<Integer> el = new ArrayList<Integer>();
    for (int i = 1; i <= n; i++) el.add(i);
    getPerm(el, new ArrayList<Integer>(), pq);
    //System.out.println(pq.size());
    Perm mth = new Perm(el);
    for (int i = 0; i < m; i++) {
      mth = pq.poll();
    }

    System.out.println(mth);// + " " + mth.f);

  }

  private static void getPerm(List<Integer> el,
                              List<Integer> cp,
                              PriorityQueue<Perm> pq) {
    if (el.size() == 0) {
      Perm p = new Perm(cp);
      pq.add(p);
      return;
    }

    for (int i = 0; i < el.size(); i++) {
      List<Integer> clone = new ArrayList<Integer>(el);
      int e = clone.get(i);
      clone.remove(i);
      cp.add(e);
      getPerm(clone, cp, pq);
      cp.remove(cp.size() - 1);
    }

    return;

  }

  private static class Perm {

    List<Integer> a;
    int f;

    public static Comparator<Perm> cmp = new Comparator<Perm>() {
      public int compare(Perm p1, Perm p2) {
        int f1 = p1.f;
        int f2 = p2.f;
        if (f1 > f2) return -1;
        if (f2 > f1) return 1;

        List<Integer> a1 = p1.a;
        List<Integer> a2 = p2.a;

        for (int i = 0; i < a1.size(); i++) {
          int e1 = a1.get(i);
          int e2 = a2.get(i);
          if (e1 < e2) return -1;
          if (e2 < e1) return 1;
        }
        return 0;
      }
    };

    public Perm(List<Integer> perm) {
      a = new ArrayList<Integer>(perm);

      for (int i = 0; i < a.size(); i++) {
        for (int j = i; j < a.size(); j++) {
          int min = Integer.MAX_VALUE;
          for (int k = i; k <= j; k++) {
            int curr = a.get(k);
            if (curr < min) min = curr;
          }
          f += min;
        }
      }
    }
    @Override
    public String toString() {
      StringBuilder sb = new StringBuilder();
      for (int i = 0; i < a.size(); i++) {
        sb.append(a.get(i));
        if (i != a.size() - 1) sb.append(" ");
      }
      sb.append(System.getProperty("line.separator"));
      return sb.toString();
    }
  }
}


//package hiougyf;
import java.io.*;
import java.util.*;
import java.util.Map.Entry;

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

		//String ans="10";
		int n=sc.nextInt();
	int j=0,ans=0;
	for(int i=1;i<100000000;i++) {
		int m=i;
		if(n==0) {
			System.out.println(i-1);
			break;
		}
		j=0;
				while(m>0) {
					int k=m%10;
					m/=10;
					j+=k;
				}
				if(j==10) n--;
		}
	}
	  public static int floorSqrt(int x)
	    {
	        // Base Cases
	        if (x == 0 || x == 1)
	            return x;

	        // Do Binary Search for floor(sqrt(x))
	        int start = 1, end = x, ans=0;
	        while (start <= end)
	        {
	            int mid = (start + end) / 2;

	            // If x is a perfect square
	            if (mid*mid == x)
	                return mid;

	            // Since we need floor, we update answer when mid*mid is
	            // smaller than x, and move closer to sqrt(x)
	            if (mid*mid < x)
	            {
	                start = mid + 1;
	                ans = mid;
	            }
	            else   // If mid*mid is greater than x
	                end = mid-1;
	        }
	        return ans;
	    }
		static int div(int n,int b) {
			int g=-1;
			for(int i=2;i<=Math.sqrt(n);i++) {
				if(n%i==0&&i!=b) {
					g=i;
					break;
				}
			}
			return g;
		}

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

	        return gcd(b%a, a);
	    }
	   public static int lcm(int a, int b)
	  {
	     return (a*b)/gcd(a, b);
	  }
	   public static boolean isPrime1(int n) {
           if (n <= 1) {
               return false;
           }
           if (n == 2) {
               return true;
           }
           for (int i = 2; i <= Math.sqrt(n) + 1; i++) {
               if (n % i == 0) {
                   return false;
               }
           }
           return true;
       }
       public static boolean isPrime(int n) {
           if (n <= 1) {
               return false;
           }
           if (n == 2) {
               return true;
           }
           if (n % 2 == 0) {
               return false;
           }
           for (int i = 3; i <= Math.sqrt(n) + 1; i = i + 2) {
               if (n % i == 0) {
                   return false;
               }
           }
           return true;
       }

}


import java.util.Scanner;

/**
 * Created by Peter on 13.04.2016.
 */
public class TaskA {
    int n, b, p;
    TaskA(Scanner sc) {
        n = sc.nextInt();
        b = sc.nextInt();
        p = sc.nextInt();

    }
    private int getGamePlayed() {
        int nn = n;
        int ans = 0;
        while (nn > 1 ) {
            int k = 1;
            while (k*2 <= nn) {
                k *= 2;
            }
            ans += k/2;
            nn = nn - k/2;

        }
        return ans;
    }

    private void solve(){
        int totalP = p * n;
        int gamePlayed = getGamePlayed();
        int totalB = gamePlayed * (2 * b + 1);
        System.out.printf("%d %d", totalB, totalP);
    }

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


        import java.io.*;
import java.math.RoundingMode;
import java.util.*;
        public class cf450A {
            static PrintWriter out;
            public static void main(String[] args) throws IOException {
                MyScanner sc = new MyScanner();
                out = new PrintWriter(new BufferedOutputStream(System.out));
                int n = sc.nextInt(), m = sc.nextInt(), idx = 0, tempVal = 0;
                for(int i = 0; i < n; i ++){
                    double val = sc.nextDouble();
                    int current = (int)Math.ceil((val/(double)m)-(int)(val/m))+(int)(val/m);
                    if(current>=tempVal){
                        tempVal = current;
                        idx = i+1;
                    }
                }
                out.println(idx);
                out.close();
            }
            static class MyScanner {
                BufferedReader br;
                StringTokenizer st;
                public MyScanner() {
                    br = new BufferedReader(new InputStreamReader(System.in));
                }
                String next() {
                    while (st == null || !st.hasMoreElements()) {
                        try {
                            st = new StringTokenizer(br.readLine());
                        } catch (IOException e) {
                            e.printStackTrace();
                        }
                    }
                    return st.nextToken();
                }
                int nextInt() {
                    return Integer.parseInt(next());
                }
                long nextLong() {
                    return Long.parseLong(next());
                }
                double nextDouble() {
                    return Double.parseDouble(next());
                }
                String nextLine() {
                    String str = "";
                    try {
                        str = br.readLine();
                    } catch (IOException e) {
                        e.printStackTrace();
                    }
                    return str;
                }
            }
        }


import java.util.*;
public class hexa
{

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

        int n=scan.nextInt();
        long pre[]=new long[1024];
        for(int j=0;j<1024;j++)
        pre[j]=Long.parseLong(Integer.toBinaryString(j));
        int g=0;
        for(g=0;g<1024;g++)
        {
            if(pre[g]>n)
            break;

        }
        System.out.print(g-1);

    }
}


//package main;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

public class Main {

	static List<Integer> primeGenerator(int max) {
		boolean[] isNotPrime = new boolean[max];

		for(int i = 2; i < max; i++) {
			if(isNotPrime[i]) continue;

			isNotPrime[i] = false;
			for(int j = i + i; j < max; j += i) {
				isNotPrime[j] = true;
			}
		}

		List<Integer> list = new ArrayList<Integer>();

		for(int i = 2; i < max; i++) {
			if(!isNotPrime[i]) list.add(i);
		}

		return list;
	}

	static List<Long> getPrimeFactors(long n) {
		List<Integer> primes = primeGenerator(1000001);

		List<Long> primeFactors = new ArrayList<>();

		int index = 0;
		while(n > 1 && index < primes.size()) {
			int prime = primes.get(index);
			int pow = 0;
			while(n % prime == 0) {
				n /= prime;
				pow++;
			}
			index++;
			if(pow > 0)
				primeFactors.add((long)Math.pow(prime, pow));
		}
		if(n > 1)
			if(isPrime((int)n)) primeFactors.add(n);
			else System.exit(31);

		return primeFactors;

	}

	static class Pair {
		long value;
		int index;
		Pair(long value, int index) {
			this.value = value;
			this.index = index;
		}
	}

	static boolean isPrime(int n) {
		if(n % 2 == 0) return false;

		int sqrt = (int)Math.sqrt(n);

		for(int i = 3; i <= sqrt; i += 2) {
			if(n % i == 0) return false;
		}

		return true;
	}

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

		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		String[] data = reader.readLine().split("\\s+");
		reader.close();

		long l = Integer.parseInt(data[0]);
		long r = Integer.parseInt(data[1]);
		long x = Integer.parseInt(data[2]);
		long y = Integer.parseInt(data[3]);

		if((y % x) != 0) {
			System.out.println(0);
			return;
		}

		if(x == y) {
			if(x < l || y > r) System.out.println(0);
			else System.out.println(1);
			return;
		}

		long part = y / x;

		List<Long> primeFactors = getPrimeFactors(part);

		List<Pair> temp1 = new ArrayList<>();

		int ans = 0;

		for(int i = 0; i < primeFactors.size(); i++) {
			long val = primeFactors.get(i);
			long f1 = x * (val);
			long f2 = x * (part / val);

			if(Math.min(f1, f2) >= l && Math.max(f1, f2) <= r) ans++;

			temp1.add(new Pair(val, i+1));

		}

		List<Pair> temp2 = new ArrayList<>();
		while(!temp1.isEmpty()) {
			temp2.clear();
			for(Pair p: temp1) {
				for(int i = p.index; i < primeFactors.size(); i++) {
					long val = p.value * primeFactors.get(i);
					long f1 = x * (val);
					long f2 = x * (part / val);

					if(Math.min(f1, f2) >= l && Math.max(f1, f2) <= r) ans++;

					temp2.add(new Pair(val, i + 1));
				}
			}

			List<Pair> temp = temp1;
			temp1 = temp2;
			temp2 = temp;
		}

		if(x >= l && y <= r) ans++;

		System.out.println(ans);
	}
}


import java.util.HashMap;
import java.util.Scanner;

public class mg3 {
  public static void main(String args[]){
	  int score =0;
	  String[] arrayS = {"zero","one","two","three","four","five","six","seven","eight","nine","ten","eleven","twelve","thirteen","fourteen","fifteen","sixteen","seventeen","eighteen",
			  "nineteen","twenty","thirty","forty","fifty","sixty","seventy","eighty","ninety"};
	  HashMap<Integer,String> array = new HashMap<Integer,String>();
	  for(int i =0; i<=19;i++){
		  array.put(i, arrayS[i]);
	  }
	  for(int j = 2;j<=9;j++){
		  array.put(10*j, arrayS[18+j]);
	  }
	  Scanner in = new Scanner(System.in);
	  score = Integer.parseInt(in.nextLine());
	  StringBuilder s= new StringBuilder();
	  if(score<=20||score%10==0){
		  s.append(array.get(score));
	  }
	  else {
		  int item = score%10;
		  score = score/10;
		  s.append(array.get(score*10)+"-");
		  s.append(array.get(item));
	  }
	  System.out.println(s.toString());

  }
}


import java.util.*;
import java.io.*;
public class Main{
    public static String threedoors(int k,int arr[],int door,int total){
        if(k==0&&total<3)return "NO";
        if(total>=3)return "YES";
        k=arr[k-1];
        return threedoors(k,arr,k,total+1);
    }

    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        while(n-->0){
            int k=sc.nextInt();
            int arr[]=new int[3];
            int i=0;
            while(i<3){
                arr[i]=sc.nextInt();
                i++;
            }
            System.out.println(threedoors(k,arr,k,0));
        }
    }
}