import java.util.*;

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

/**
 * @author Naitik
 *
 */
public class Main

{
	 static FastReader sc=new FastReader();
	 static long dp[][][];
	 //static int v[][];
	 static int mod=998244353;;
//	 static int mod=1000000007;
	 static long max;
	 static long bit[];
	 static long bit1[];
//	 static long seg[];
	 //static long fact[];
//	 static long A[];
	// static TreeMap<Integer,Integer> map;
	 //static StringBuffer sb=new StringBuffer("");
	 static HashMap<Integer,Integer> map;
	   static PrintWriter out=new PrintWriter(System.out);
	  public static void main(String[] args)
{

		 //  StringBuffer sb=new StringBuffer("");
		  int ttt=1;
		     // ttt =i();
	        outer :while (ttt-- > 0)
			{
	        	char A[]=s().toCharArray();
	        	if(A.length==1 && A[0]=='0') {
	        		System.out.println("1");
	        		return;
	        	}
	        	if(A[0]=='0') {
	        		System.out.println("0");
	        		return;
	        	}
	        	if(A.length==1) {
	        		if(A[0]=='X' || A[0]=='_') {
	        			System.out.println("1");
	        			return;
	        		}
	        	}
	        	dp=new long[A.length+1][25][11];
	        	fill(dp);
	        	System.out.println(go(A, 0, 0, 10));

	        }
	        //System.out.println(sb.toString());
		     out.close();

	    //CHECK FOR N=1                    //CHECK FOR M=0
        //CHECK FOR N=1                    //CHECK FOR M=0
       	//CHECK FOR N=1

    }
	  static long go(char A[],int i,int pv,int v) {
		  if(i==A.length) {
			  if(pv==0)
				  return 1;
			  return 0;
		  }
		  if(dp[i][pv][v]!=-1)
			  return dp[i][pv][v];
		  long ans=0;
		  if(A[i]=='_') {
			  for(int j=0;j<10;j++) {
				  if(i==0 && j==0)
					  continue;
				  int y=pv*10+j;
				  y%=25;
				  ans+=go(A, i+1, y, v);
			  }
		  }
		  else if(A[i]=='X') {
			  if(v!=10) {
				  ans+=go(A, i+1, (pv*10+v)%25, v);
			  }
			  else {
				  for(int j=0;j<10;j++) {
					  if(i==0 && j==0)
						  continue;
					  int y=pv*10+j;
					  y%=25;
					  ans+=go(A, i+1, y, j);
				  }
			  }
		  }
		  else {
			  ans+=go(A, i+1, (pv*10+A[i]-'0')%25, v);
		  }
		  return dp[i][pv][v]=ans;
	  }

static class Pair implements Comparable<Pair>
     {
    	 int x;
    	 int y;
    	 int z;
    	 Pair(int x,int y){
    		 this.x=x;
    		 this.y=y;
    		// this.z=z;

    	 }
		@Override
		public int compareTo(Pair o) {
			if(this.x>o.x)
				return +1;
			else if(this.x<o.x)
				return -1;
			else {
				if(this.y>o.y)
					return 1;
				else if(this.y<o.y)
					return -1;
				else
					return 0;
			}
		}
//		public int hashCode()
//		{
//			final int temp = 14;
//			int ans = 1;
//			ans =x*31+y*13;
//			return ans;
//		}
//		@Override
//		public boolean equals(Object o)
//		{
//			if (this == o) {
//				return true;
//			}
//			if (o == null) {
//				return false;
//			}
//			if (this.getClass() != o.getClass()) {
//				return false;
//			}
//			Pair other = (Pair)o;
//			if (this.x != other.x || this.y!=other.y) {
//				return false;
//			}
//			return true;
//		}
//
		/* FOR TREE MAP PAIR USE */

//		public int compareTo(Pair o) {
// 			if (x > o.x) {
// 				return 1;
// 			}
// 			if (x < o.x) {
// 				return -1;
// 			}
// 			if (y > o.y) {
// 				return 1;
// 			}
// 			if (y < o.y) {
// 				return -1;
// 			}
// 			return 0;
// 		}

     }

//static int find(int A[],int a) {
//	  if(A[a]<0)
//		  return a;
//	  return A[a]=find(A, A[a]);
//}
static int find(int A[],int a) {
	  if(A[a]==a)
		  return a;
	  return A[a]=find(A, A[a]);
}
//FENWICK TREE
static void update(int i, int x){
	for(; i < bit.length; i += (i&-i))
		bit[i] += x;
}

static int sum(int i){
	int ans = 0;
	for(; i > 0; i -= (i&-i))
		ans += bit[i];
	return ans;
}
static void update1(int i, long x){
	for(; i < bit1.length; i += (i&-i))
		bit1[i] += x;
}

static int sum1(int i){
	int ans = 0;
	for(; i > 0; i -= (i&-i))
		ans += bit1[i];
	return ans;
}
//END
static void add(int v) {
	if(!map.containsKey(v)) {
		map.put(v, 1);
	}
	else {
		map.put(v, map.get(v)+1);
	}
}
static void remove(int v) {
	if(map.containsKey(v)) {
		map.put(v, map.get(v)-1);
		if(map.get(v)==0)
			map.remove(v);
	}
}
public static int upper(int A[],int k,int si,int ei)
{
	int l=si;
	int u=ei;
	int ans=-1;
	while(l<=u) {
		int mid=(l+u)/2;
		if(A[mid]<=k) {
			ans=mid;
			l=mid+1;
		}
		else {
			u=mid-1;
		}
	}
	return ans;
}
public static int lower(int A[],int k,int si,int ei)
{
	int l=si;
	int u=ei;
	int ans=-1;
	while(l<=u) {
		int mid=(l+u)/2;
		if(A[mid]<=k) {
			l=mid+1;
		}
		else {
			ans=mid;
			u=mid-1;
		}
	}
	return ans;

}
static int[] copy(int A[]) {
	int B[]=new int[A.length];
	for(int i=0;i<A.length;i++) {
		B[i]=A[i];
	}
	return B;
}
static long[] copy(long A[]) {
	long B[]=new long[A.length];
	for(int i=0;i<A.length;i++) {
		B[i]=A[i];
	}
	return B;
}
static int[] input(int n) {
	int A[]=new int[n];
	   for(int i=0;i<n;i++) {
		   A[i]=sc.nextInt();
	   }
	   return A;
   }
static long[] inputL(int n) {
	long A[]=new long[n];
	   for(int i=0;i<n;i++) {
		   A[i]=sc.nextLong();
	   }
	   return A;
   }
static String[] inputS(int n) {
	String A[]=new String[n];
	   for(int i=0;i<n;i++) {
		   A[i]=sc.next();
	   }
	   return A;
   }
static long sum(int A[]) {
	long sum=0;
	for(int i : A) {
		sum+=i;
	}
	return sum;
}
static long sum(long A[]) {
	long sum=0;
	for(long i : A) {
		sum+=i;
	}
	return sum;
}
static void reverse(long A[]) {
	int n=A.length;
	long B[]=new long[n];
	for(int i=0;i<n;i++) {
		B[i]=A[n-i-1];
	}
	for(int i=0;i<n;i++)
		A[i]=B[i];

}
static void reverse(int A[]) {
	int n=A.length;
	int B[]=new int[n];
	for(int i=0;i<n;i++) {
		B[i]=A[n-i-1];
	}
	for(int i=0;i<n;i++)
		A[i]=B[i];

}
static void input(int A[],int B[]) {
	   for(int i=0;i<A.length;i++) {
		   A[i]=sc.nextInt();
		   B[i]=sc.nextInt();
	   }
}
static int[][] input(int n,int m){
	int A[][]=new int[n][m];
	for(int i=0;i<n;i++) {
		for(int j=0;j<m;j++) {
			A[i][j]=i();
		}
	}
	return A;
}
static char[][] charinput(int n,int m){
	char A[][]=new char[n][m];
	for(int i=0;i<n;i++) {
		String s=s();
		for(int j=0;j<m;j++) {
			A[i][j]=s.charAt(j);
		}
	}
	return A;
}

static int max(int A[]) {
	int max=Integer.MIN_VALUE;
	for(int i=0;i<A.length;i++) {
		max=Math.max(max, A[i]);
	}
	return max;
}
static int min(int A[]) {
	int min=Integer.MAX_VALUE;
	for(int i=0;i<A.length;i++) {
		min=Math.min(min, A[i]);
	}
	return min;
}
static long max(long A[]) {
	long max=Long.MIN_VALUE;
	for(int i=0;i<A.length;i++) {
		max=Math.max(max, A[i]);
	}
	return max;
}
static long min(long A[]) {
	long min=Long.MAX_VALUE;
	for(int i=0;i<A.length;i++) {
		min=Math.min(min, A[i]);
	}
	return min;
}
static long [] prefix(long A[]) {
	long p[]=new long[A.length];
	p[0]=A[0];
	for(int i=1;i<A.length;i++)
		p[i]=p[i-1]+A[i];
	return p;
}
static long [] prefix(int A[]) {
	long p[]=new long[A.length];
	p[0]=A[0];
	for(int i=1;i<A.length;i++)
		p[i]=p[i-1]+A[i];
	return p;
}
static long [] suffix(long A[]) {
	long p[]=new long[A.length];
	p[A.length-1]=A[A.length-1];
	for(int i=A.length-2;i>=0;i--)
		p[i]=p[i+1]+A[i];
	return p;
}
static long [] suffix(int A[]) {
	long p[]=new long[A.length];
	p[A.length-1]=A[A.length-1];
	for(int i=A.length-2;i>=0;i--)
		p[i]=p[i+1]+A[i];
	return p;
}
static void fill(int dp[]) {
	Arrays.fill(dp, -1);
}
static void fill(int dp[][]) {
	for(int i=0;i<dp.length;i++)
	Arrays.fill(dp[i], -1);
}
static void fill(int dp[][][]) {
	for(int i=0;i<dp.length;i++) {
		for(int j=0;j<dp[0].length;j++) {
			Arrays.fill(dp[i][j],-1);
		}
	}
}
static void fill(int dp[][][][]) {
	for(int i=0;i<dp.length;i++) {
		for(int j=0;j<dp[0].length;j++) {
			for(int k=0;k<dp[0][0].length;k++) {
			Arrays.fill(dp[i][j][k],-1);
			}
		}
	}
}
static void fill(long dp[]) {
	Arrays.fill(dp, -1);
}
static void fill(long dp[][]) {
	for(int i=0;i<dp.length;i++)
	Arrays.fill(dp[i], -1);
}
static void fill(long dp[][][]) {
	for(int i=0;i<dp.length;i++) {
		for(int j=0;j<dp[0].length;j++) {
			Arrays.fill(dp[i][j],-1);
		}
	}
}
static void fill(long dp[][][][]) {
	for(int i=0;i<dp.length;i++) {
		for(int j=0;j<dp[0].length;j++) {
			for(int k=0;k<dp[0][0].length;k++) {
			Arrays.fill(dp[i][j][k],-1);
			}
		}
	}
}
static int min(int a,int b) {
	return Math.min(a, b);
}
static int min(int a,int b,int c) {
	return Math.min(a, Math.min(b, c));
}
static int min(int a,int b,int c,int d) {
	return Math.min(a, Math.min(b, Math.min(c, d)));
}
static int max(int a,int b) {
	return Math.max(a, b);
}
static int max(int a,int b,int c) {
	return Math.max(a, Math.max(b, c));
}
static int max(int a,int b,int c,int d) {
	return Math.max(a, Math.max(b, Math.max(c, d)));
}
static long min(long a,long b) {
	return Math.min(a, b);
}
static long min(long a,long b,long c) {
	return Math.min(a, Math.min(b, c));
}
static long min(long a,long b,long c,long d) {
	return Math.min(a, Math.min(b, Math.min(c, d)));
}
static long max(long a,long b) {
	return Math.max(a, b);
}
static long max(long a,long b,long c) {
	return Math.max(a, Math.max(b, c));
}
static long max(long a,long b,long c,long d) {
	return Math.max(a, Math.max(b, Math.max(c, d)));
}

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

	if(y==0)
		return 1;
	if(x==0)
		return 0;
    long res = 1;
    x = x % p;

    while (y > 0) {

        if (y % 2 == 1)
            res = (res * x) % p;

        y = y >> 1;
        x = (x * x) % p;
    }

    return res;
}
static long power(long x, long y)
{

	if(y==0)
		return 1;
	if(x==0)
		return 0;
    long res = 1;

    while (y > 0) {

        if (y % 2 == 1)
            res = (res * x);

        y = y >> 1;
        x = (x * x);
    }

    return res;
}
static void print(int A[]) {
	for(int i : A) {
		System.out.print(i+" ");
	}
	System.out.println();
}
static void print(long A[]) {
	for(long i : A) {
		System.out.print(i+" ");
	}
	System.out.println();
}
static long mod(long x) {
	  return ((x%mod + mod)%mod);
}
static String reverse(String s) {
	StringBuffer p=new StringBuffer(s);
	p.reverse();
	return p.toString();
}

     static int i() {
    	 return sc.nextInt();
     }
     static String s() {
    	 return sc.next();
     }
     static long l() {
    	 return sc.nextLong();
     }
     static void sort(int[] A){
        int n = A.length;
        Random rnd = new Random();
        for(int i=0; i<n; ++i){
            int tmp = A[i];
            int randomPos = i + rnd.nextInt(n-i);
            A[i] = A[randomPos];
            A[randomPos] = tmp;
        }
        Arrays.sort(A);
     }
     static void sort(long[] A){
	        int n = A.length;
	        Random rnd = new Random();
	        for(int i=0; i<n; ++i){
	            long tmp = A[i];
	            int randomPos = i + rnd.nextInt(n-i);
	            A[i] = A[randomPos];
	            A[randomPos] = tmp;
	        }
	        Arrays.sort(A);
	     }
  static String sort(String s) {
 	 Character ch[]=new Character[s.length()];
 	 for(int i=0;i<s.length();i++) {
 		 ch[i]=s.charAt(i);
 	 }
 	 Arrays.sort(ch);
 	 StringBuffer st=new StringBuffer("");
 	 for(int i=0;i<s.length();i++) {
 		 st.append(ch[i]);
 	 }
 	 return st.toString();
  }
  static HashMap<Integer,Integer> hash(int A[]){
	  HashMap<Integer,Integer> map=new HashMap<Integer, Integer>();
	  for(int i : A) {
		  if(map.containsKey(i)) {
			  map.put(i, map.get(i)+1);
		  }
		  else {
			  map.put(i, 1);
		  }
	  }
	  return map;
  }
  static TreeMap<Integer,Integer> tree(int A[]){
	  TreeMap<Integer,Integer> map=new TreeMap<Integer, Integer>();
	  for(int i : A) {
		  if(map.containsKey(i)) {
			  map.put(i, map.get(i)+1);
		  }
		  else {
			  map.put(i, 1);
		  }
	  }
	  return map;
  }
     static boolean prime(int n)
	    {
	        if (n <= 1)
	            return false;
	        if (n <= 3)
	            return true;
	        if (n % 2 == 0 || n % 3 == 0)
	            return false;
	        double sq=Math.sqrt(n);

	        for (int i = 5; i <= sq; i = i + 6)
	            if (n % i == 0 || n % (i + 2) == 0)
	                return false;
	        return true;
	    }
     static boolean prime(long n)
	    {
	        if (n <= 1)
	            return false;
	        if (n <= 3)
	            return true;
	        if (n % 2 == 0 || n % 3 == 0)
	            return false;
	        double sq=Math.sqrt(n);

	        for (int i = 5; i <= sq; i = i + 6)
	            if (n % i == 0 || n % (i + 2) == 0)
	                return false;
	        return true;
	    }
     static int gcd(int a, int b)
     {
         if (a == 0)
             return b;
         return gcd(b % a, a);
     }
     static long gcd(long a, long b)
     {
         if (a == 0)
             return b;
         return gcd(b % a, a);
     }

    static class FastReader
    {
        BufferedReader br;
        StringTokenizer st;

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

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

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

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

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

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


https://codeforces.com/problemset/submit/*
25
Any numbers that end in 00, 25, 50, or 75 will work - after can end in any groups of digits (can do casework on all possible endings) - just test if a certain starting group is possible - may also influence rest of string if one of the digits is an X
*/
import java.util.*;
import java.io.*;

public class Main{
  public static char[] str;
  public static String[] ends = {"00", "25", "50", "75"};
  public static long ret;
  public static void main(String[] args) throws IOException{
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

    str = br.readLine().toCharArray();
    ret = 0;
    if(str.length >= 2) for(int a = 0; a < 4; a++) match(str[str.length - 2], str[str.length - 1], ends[a]);
    else{
      if(str[0] == '0' || str[0] == 'X' || str[0] == '_') ret++; //only 0 possible, 0 divisible by 25
    }

    System.out.println(ret);

    br.close();
  }
  public static void match(char f, char s, String b){
    //assume a is from the original string, b is the checking string
    char f2 = f;
    char s2 = s;
    if(f == '_' && b.charAt(0) == '0' && str.length - 2 == 0) return;
    if(f2 == 'X'){
      //try to change f to the start of b
      f2 = b.charAt(0);
      if(s2 == 'X') s2 = b.charAt(0);
    }
    if(s2 == 'X'){
      //try to change s to the end of b
      s2 = b.charAt(1);
      if(f2 == 'X') f2 = b.charAt(1);
    }
    if(f2 == '_'){
      //try to change f to the start of b
      f2 = b.charAt(0);
    }
    if(s2 == '_'){
      //try to change s to the end of b
      s2 = b.charAt(1);
    }
    char cv = 'n'; //if f was X or s was X then xVal changes
    if(f == 'X') cv = f2;
    if(s == 'X') cv = s2;
    //System.out.println(f2 + " " + s2 + " " + b);
    if(f2 == b.charAt(0) && s2 == b.charAt(1)) poss(cv);
  }
  public static void poss(char xVal){
    //xVal = -1 if xs not filled yet
    //System.out.println("test " + xVal);
    if((xVal == '0' && str[0] == 'X') || str[0] == '0') return; //cannot start with a 0
    long add = 1;
    boolean xF = false; //whether or not we set X
    if(xVal != 'n') xF = true;
    for(int a = 0; a < str.length - 2; a++){
      if(str[a] == '_'){
        if(a == 0) add *= 9; //1 2 3 4 5 6 7 8 9
        else add *= 10;
      }
      if(!xF && str[a] == 'X'){
        xF = true;
        if(a == 0) add *= 9;
        else add *= 10;
      }
    }
    //System.out.println("add " + add);
    ret += add;
  }
}


import java.io.*;
import java.lang.Math;
import java.lang.reflect.Array;
import java.util.*;
import javax.swing.text.DefaultStyledDocument.ElementSpec;

public final class Solution {

  static BufferedReader br = new BufferedReader(
    new InputStreamReader(System.in)
  );
  static BufferedWriter bw = new BufferedWriter(
    new OutputStreamWriter(System.out)
  );
  static StringTokenizer st;

  /*write your constructor and global variables here*/

  static class sortCond implements Comparator<Pair<Integer, Integer>> {

    @Override
    public int compare(Pair<Integer, Integer> p1, Pair<Integer, Integer> p2) {
      if (p1.a <= p2.a) {
        return -1;
      } else {
        return 1;
      }
    }
  }

  static class Rec {

    int a;
    int b;
    long c;

    Rec(int a, int b, long c) {
      this.a = a;
      this.b = b;
      this.c = c;
    }
  }

  static class Pair<f, s> {

    f a;
    s b;

    Pair(f a, s b) {
      this.a = a;
      this.b = b;
    }
  }

  interface modOperations {
    int mod(int a, int b, int mod);
  }

  static int findBinaryExponentian(int a, int pow, int mod) {
    if (pow == 1) {
      return a;
    } else if (pow == 0) {
      return 1;
    } else {
      int retVal = findBinaryExponentian(a, (int) pow / 2, mod);
      int val = (pow % 2 == 0) ? 1 : a;
      return modMul.mod(modMul.mod(retVal, retVal, mod), val, mod);
    }
  }

  static int findPow(int a, int b, int mod) {
    if (b == 1) {
      return a % mod;
    } else if (b == 0) {
      return 1;
    } else {
      int res = findPow(a, (int) b / 2, mod);
      return modMul.mod(res, modMul.mod(res, (b % 2 == 1 ? a : 1), mod), mod);
    }
  }

  static int bleft(int ele, int[] sortedArr) {
    int l = 0;
    int h = sortedArr.length - 1;
    int ans = -1;
    while (l <= h) {
      int mid = l + (int) (h - l) / 2;
      if (sortedArr[mid] < ele) {
        ans = mid;
        l = mid + 1;
      } else if (sortedArr[mid] >= ele) {
        h = mid - 1;
      }
    }
    return ans;
  }

  static int gcd(int a, int b) {
    int div = b;
    int rem = a % b;
    while (rem != 0) {
      int temp = rem;
      rem = div % rem;
      div = temp;
    }
    return div;
  }

  static long[] log(long no, long n) {
    long i = 1;
    int cnt = 0;
    long sum = 0l;
    long arr[] = new long[2];
    while (i < no) {
      sum += i;
      cnt++;
      if (sum == n) {
        arr[0] = 1l * cnt;
        arr[1] = sum;
        break;
      }
      i *= 2l;
    }
    if (arr[0] == 0) {
      arr[0] = cnt;
      arr[1] = sum;
    }
    return arr;
  }

  static modOperations modAdd = (int a, int b, int mod) -> {
    return (a % mod + b % mod) % mod;
  };
  static modOperations modSub = (int a, int b, int mod) -> {
    return (int) ((1l * a % mod - 1l * b % mod + 1l * mod) % mod);
  };
  static modOperations modMul = (int a, int b, int mod) -> {
    return (int) ((1l * (a % mod) * 1l * (b % mod)) % (1l * mod));
  };
  static modOperations modDiv = (int a, int b, int mod) -> {
    return modMul.mod(a, findBinaryExponentian(b, mod - 1, mod), mod);
  };

  static HashSet<Integer> primeList(int MAXI) {
    int[] prime = new int[MAXI + 1];
    HashSet<Integer> obj = new HashSet<>();
    for (int i = 2; i <= (int) Math.sqrt(MAXI) + 1; i++) {
      if (prime[i] == 0) {
        obj.add(i);
        for (int j = i * i; j <= MAXI; j += i) {
          prime[j] = 1;
        }
      }
    }
    for (int i = (int) Math.sqrt(MAXI) + 1; i <= MAXI; i++) {
      if (prime[i] == 0) {
        obj.add(i);
      }
    }
    return obj;
  }

  static int[] factorialList(int MAXI, int mod) {
    int[] factorial = new int[MAXI + 1];
    factorial[2] = 1;
    for (int i = 3; i < MAXI + 1; i++) {
      factorial[i] = modMul.mod(factorial[i - 1], i, mod);
    }
    return factorial;
  }

  static void put(HashMap<Integer, Integer> cnt, int key) {
    if (cnt.containsKey(key)) {
      cnt.replace(key, cnt.get(key) + 1);
    } else {
      cnt.put(key, 1);
    }
  }

  static long arrSum(ArrayList<Long> arr) {
    long tot = 0;
    for (int i = 0; i < arr.size(); i++) {
      tot += arr.get(i);
    }
    return tot;
  }

  static int ord(char b) {
    return (int) b - (int) 'a';
  }

  static int optimSearch(int[] cnt, int lower_bound, int pow, int n) {
    int l = lower_bound + 1;
    int h = n;
    int ans = 0;
    while (l <= h) {
      int mid = l + (h - l) / 2;
      if (cnt[mid] - cnt[lower_bound] == pow) {
        return mid;
      } else if (cnt[mid] - cnt[lower_bound] < pow) {
        ans = mid;
        l = mid + 1;
      } else {
        h = mid - 1;
      }
    }
    return ans;
  }

  static Pair<Long, Integer> ret_ans(ArrayList<Integer> ans) {
    int size = ans.size();
    int mini = 1000000000 + 1;
    long tit = 0l;
    for (int i = 0; i < size; i++) {
      tit += 1l * ans.get(i);
      mini = Math.min(mini, ans.get(i));
    }
    return new Pair<>(tit - mini, mini);
  }

  static int factorList(
    HashMap<Integer, Integer> maps,
    int no,
    int maxK,
    int req
  ) {
    int i = 1;
    while (i * i <= no) {
      if (no % i == 0) {
        if (i != no / i) {
          put(maps, no / i);
        }
        put(maps, i);
        if (maps.get(i) == req) {
          maxK = Math.max(maxK, i);
        }
        if (maps.get(no / i) == req) {
          maxK = Math.max(maxK, no / i);
        }
      }
      i++;
    }
    return maxK;
  }

  static ArrayList<Integer> getKeys(HashMap<Integer, Integer> maps) {
    ArrayList<Integer> vals = new ArrayList<>();
    for (Map.Entry<Integer, Integer> map : maps.entrySet()) {
      vals.add(map.getKey());
    }
    return vals;
  }

  static ArrayList<Integer> getValues(HashMap<Integer, Integer> maps) {
    ArrayList<Integer> vals = new ArrayList<>();
    for (Map.Entry<Integer, Integer> map : maps.entrySet()) {
      vals.add(map.getValue());
    }
    return vals;
  }

  static int getMax(ArrayList<Integer> arr) {
    int max = arr.get(0);
    for (int i = 1; i < arr.size(); i++) {
      if (arr.get(i) > max) {
        max = arr.get(i);
      }
    }
    return max;
  }

  static int getMin(ArrayList<Integer> arr) {
    int max = arr.get(0);
    for (int i = 1; i < arr.size(); i++) {
      if (arr.get(i) < max) {
        max = arr.get(i);
      }
    }
    return max;
  }

  static int list[][] = { { -1, 0 }, { 0, 1 }, { 1, 0 }, { 0, -1 } };

  /*write your  methods and classes here*/

  public static void main(String[] args) throws IOException {
    String s = br.readLine();
    int n = s.length();
    if (
      (s.charAt(0) == '0' || s.charAt(0) == '_' || s.charAt(0) == 'X') &&
      s.length() == 1
    ) {
      bw.write("1\n");
      bw.flush();
    } else if (s.length() == 1) {
      bw.write("0\n");
      bw.flush();
    } else if (s.charAt(0) == '0') {
      bw.write("0\n");
      bw.flush();
    } else {
      String digits[] = { "25", "50", "75", "00" };
      String arr1[] = { "__", "_X", "X_", "XX" };
      int way[] = { 4, 4, 4, 1 };
      way[1] = s.charAt(0) == 'X' ? 2 : 4;
      way[2] = s.charAt(0) == 'X' ? 3 : 4;
      way[0] = s.length() == 2 ? 3 : 4;
      way[1] = s.length() == 2 ? 3 : 4;
      int ways = 0;
      String v = s.substring(n - 2, n);
      for (i = 0; i < 4; i++) {
        if (v.equals(digits[i])) {
          ways = 1;
        }
      }
      if (v.charAt(0) == '_' || v.charAt(0) == 'X') {
        ways = 2;
        if (v.charAt(1) == '0' && s.charAt(0) == 'X') {
          ways = 1;
        }
      } else if (v.charAt(1) == '_' || v.charAt(1) == 'X') {
        ways = 1;
      }
      for (i = 0; i < 4; i++) {
        if (v.equals(arr1[i])) {
          //System.out.println("age");
          ways = way[i];
        }
      }
      if (v == "XX" && s.charAt(0) == 'X') {
        ways = 0;
      }
      if (
        v.charAt(0) != '2' &&
        v.charAt(0) != '5' &&
        v.charAt(0) != '7' &&
        v.charAt(0) != '0' &&
        v.charAt(0) != 'X' &&
        v.charAt(0) != '_'
      ) {
        ways = 0;
      }
      if (
        v.charAt(1) != '0' &&
        v.charAt(1) != '5' &&
        v.charAt(1) != 'X' &&
        v.charAt(1) != '_'
      ) {
        ways = 0;
      }
      int xways = 1;
      if (v.charAt(0) == 'X') {
        xways = way[2];
      } else if (v.charAt(1) == 'X') {
        xways = way[1] / 2;
      } else {
        if (s.charAt(0) == 'X') {
          xways = 9;
        } else {
          xways = 10;
        }
      }

      boolean ok = false;
      long toti = 1l;
      for (i = 0; i < s.length() - 2; i++) {
        if (s.charAt(i) == 'X') {
          ok = true;
        }
        if (s.charAt(i) == '_') {
          if (i == 0) {
            toti *= 9l;
          } else {
            toti *= 10l;
          }
        }
      }
      if (ok) {
        toti *= 1l * xways;
      }
      toti *= 1l * ways;
      bw.write(Long.toString(toti) + "\n");
      bw.flush();
    }
  }
}


/*
25
Any numbers that end in 00, 25, 50, or 75 will work - after can end in any groups of digits (can do casework on all possible endings) - just test if a certain starting group is possible - may also influence rest of string if one of the digits is an X
*/
import java.util.*;
import java.io.*;

public class Main{
  public static char[] str;
  public static String[] ends = {"00", "25", "50", "75"};
  public static long ret;
  public static void main(String[] args) throws IOException{
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

    str = br.readLine().toCharArray();
    ret = 0;
    if(str.length >= 2) for(int a = 0; a < 4; a++) match(str[str.length - 2], str[str.length - 1], ends[a]);
    else{
      if(str[0] == '0') ret++; //only 0 possible, 0 divisible by 25
    }

    System.out.println(ret);

    br.close();
  }
  public static void match(char f, char s, String b){
    //assume a is from the original string, b is the checking string
    char f2 = f;
    char s2 = s;
    if(f2 == 'X'){
      //try to change f to the start of b
      f2 = b.charAt(0);
      if(s2 == 'X') s2 = b.charAt(0);
    }
    if(s2 == 'X'){
      //try to change s to the end of b
      s2 = b.charAt(1);
      if(f2 == 'X') f2 = b.charAt(1);
    }
    if(f2 == '_'){
      //try to change f to the start of b
      f2 = b.charAt(0);
    }
    if(s2 == '_'){
      //try to change s to the end of b
      s2 = b.charAt(1);
    }
    int cv = -1; //if f was X or s was X then xVal changes
    if(f == 'X') cv = f2;
    if(s == 'X') cv = s2;
    //System.out.println(f2 + " " + s2 + " " + b);
    if(f2 == b.charAt(0) && s2 == b.charAt(1)) poss(cv);
  }
  public static void poss(int xVal){
    //xVal = -1 if xs not filled yet
    //System.out.println("test " + xVal);
    if((xVal == 0 && str[0] == 'X') || if(str[0] == '0')) return; //cannot start with a 0
    long add = 1;
    boolean xF = false; //whether or not we set X
    if(xVal != -1) xF = true;
    for(int a = 0; a < str.length - 2; a++){
      if(str[a] == '_'){
        if(a == 0) add *= 9; //1 2 3 4 5 6 7 8 9
        else add *= 10;
      }
      if(!xF && str[a] == 'X'){
        xF = true;
        if(a == 0) add *= 9;
        else add *= 10;
      }
    }
    ret += add;
  }
}


public class D {
    static long[][] dp;

    public static long solve(int nodes, int height) {
        if (nodes == 0) {
            if (height == 0)
                return 1;
            return 0;
        }
        if (dp[nodes][height] != -1)
            return dp[nodes][height];
        long res = 0;
        for (int i = 0; i <= nodes - 1; i++) {
            if (height > 1) {
                res += solve(i, height - 1) * solve(nodes - 1 - i, 0)
                        + solve(i, 0) * solve(nodes - 1 - i, height - 1)
                        - solve(i, height - 1)
                        * solve(nodes - 1 - i, height - 1);
            } else {
                res += solve(i, 0) * solve(nodes - 1 - i, 0);
            }
        }
        return dp[nodes][height] = res;
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int h = sc.nextInt();
        dp = new long[n + 1][h + 1];
        for (int i = 0; i <= n; i++)
            Arrays.fill(dp[i], -1);
        System.out.println(solve(n, h));
    }
}


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

public class CF {

	void realSolve() {
		int n = in.nextInt();
		int h = in.nextInt();
		long[][] dp = new long[n + 1][n + 1];
		dp[1][1] = 1;
		dp[0][0] = 1;
		for (int cn = 2; cn <= n; cn++) {
			for (int curH = 1; curH <= n; curH++) {
				for (int id  = 1; id <= cn; id++) {
					long cur = 1;
					long v1 = 0, v2 = 0;
					for (int h1 = 0; h1 <= curH - 1; h1++) {
						v1 += dp[id - 1][h1];
						v2 += dp[cn - id][h1];
					}
					cur = v1 * dp[cn - id][curH - 1] + v2 * dp[id - 1][curH - 1] - dp[cn - id][curH - 1] * dp[id - 1][curH - 1];
					dp[cn][curH] += cur;
				}
			}
		}
		long res =0;
		for (int h1 = h; h1 <= n; h1++)
			res += dp[n][h1];
		out.println(res);
	}

	private class InputReader {
		StringTokenizer st;
		BufferedReader br;

		public InputReader(File f) {
			try {
				br = new BufferedReader(new FileReader(f));
			} catch (FileNotFoundException e) {
				e.printStackTrace();
			}
		}

		public InputReader(InputStream f) {
			br = new BufferedReader(new InputStreamReader(f));
		}

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

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

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

		boolean hasMoreElements() {
			while (st == null || !st.hasMoreElements()) {
				String s;
				try {
					s = br.readLine();
				} catch (IOException e) {
					return false;
				}
				st = new StringTokenizer(s);
			}
			return st.hasMoreElements();
		}

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

	InputReader in;
	PrintWriter out;

	void solve() {
		in = new InputReader(new File("object.in"));
		try {
			out = new PrintWriter(new File("object.out"));
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		}

		realSolve();

		out.close();
	}

	void solveIO() {
		in = new InputReader(System.in);
		out = new PrintWriter(System.out);

		realSolve();

		out.close();

	}

	public static void main(String[] args) {
		new CF().solveIO();
	}
}import java.io.*;
import java.util.*;

public class CF {

	void realSolve() {
		int n = in.nextInt();
		int h = in.nextInt();
		long[][] dp = new long[n + 1][n + 1];
		dp[1][1] = 1;
		dp[0][0] = 1;
		for (int cn = 2; cn <= n; cn++) {
			for (int curH = 1; curH <= n; curH++) {
				for (int id  = 1; id <= cn; id++) {
					long cur = 1;
					long v1 = 0, v2 = 0;
					for (int h1 = 0; h1 <= curH - 1; h1++) {
						v1 += dp[id - 1][h1];
						v2 += dp[cn - id][h1];
					}
					cur = v1 * dp[cn - id][curH - 1] + v2 * dp[id - 1][curH - 1] - dp[cn - id][curH - 1] * dp[id - 1][curH - 1];
					dp[cn][curH] += cur;
				}
			}
		}
		long res =0;
		for (int h1 = h; h1 <= n; h1++)
			res += dp[n][h1];
		out.println(res);
	}

	private class InputReader {
		StringTokenizer st;
		BufferedReader br;

		public InputReader(File f) {
			try {
				br = new BufferedReader(new FileReader(f));
			} catch (FileNotFoundException e) {
				e.printStackTrace();
			}
		}

		public InputReader(InputStream f) {
			br = new BufferedReader(new InputStreamReader(f));
		}

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

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

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

		boolean hasMoreElements() {
			while (st == null || !st.hasMoreElements()) {
				String s;
				try {
					s = br.readLine();
				} catch (IOException e) {
					return false;
				}
				st = new StringTokenizer(s);
			}
			return st.hasMoreElements();
		}

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

	InputReader in;
	PrintWriter out;

	void solve() {
		in = new InputReader(new File("object.in"));
		try {
			out = new PrintWriter(new File("object.out"));
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		}

		realSolve();

		out.close();
	}

	void solveIO() {
		in = new InputReader(System.in);
		out = new PrintWriter(System.out);

		realSolve();

		out.close();

	}

	public static void main(String[] args) {
		new CF().solveIO();
	}
}


import java.util.*;
public class Main(){
    public static class main(String[] args){

    }
}


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

public class Sol {

    static int n , h;
    static long [][][]res = new long[36][36][36];
    static long [][]ress = new long[36][36];

    static long solve(int s , int e){
        if(s == e)
            return 1;
        if(ress[s][e]!=-1)
            return ress[s][e];
        long r = 0;
        for(int i = s ; i<=e ; i++){
            if(i==s)
                r+= solve(1+1 , e);
            else if(i == e)
                r+= solve( s , i-1);
            else
                r+= solve(s , i-1)*solve(i+1,e);
        }
        return ress[s][e] = e;
    }

    static long solve(int s , int e , int l ){
        if(s == e){
            if(l+1 < h)
                return 0;
            else
                return 1;
        }
        if(res[s][e][l]!=-1)
            return res[s][e][l];

        long r = 0;
        for(int i = s ; i<= e ; i++){
            if(i== s)
                r += solve(i+1 , e , l+1);
            else if(i == e)
                r+= solve(s , i-1 , l+1);
            else{
                r += solve(s , i-1) * solve(i+1 , e , l+1);
                r+= solve(s , i-1 , l+1 ) * solve(i+1 , e);
                r-= solve(s , i-1 , l+1) * solve(i+1 , e , l+1);
            }
        }
        return res[s][e][l] = r;
    }

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

        for(int i = 0 ; i< 36 ; i++){
            Arrays.fill(ress[i], -1);
            for(int j = 0 ; j< 36 ; j++){
                Arrays.fill(res[i][j], -1);
            }
        }

        System.out.println(solve(1 , n  , 0));

    }

}


import java.util.Scanner;

public class CF_171F {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int res = 11;
		while(n > 0) {
			res += 2;
			int rev = Integer.parseInt(new StringBuffer(res + "").reverse().toString());
			if(res != rev && isPrime(res) && isPrime(rev)) {
				n--;
			}
		}

		System.out.println(res);
	}

	private static boolean isPrime(int n) {
		for(int i = 2; i <= Math.sqrt(n); i++) {
			if(n % i == 0) return false;
		}

		return true;
	}

}


import java.util.*;
public class ucyhf {
	 static Scanner in = new Scanner(System.in);
	public static void main(String args[]) {
		int a = 13;
		int count = 1;
		int stop = in.nextInt();
		while (true) {
			if (isEmirp(a)) {
				if(count ==stop){
					System.out.println(a);
					break;
				}
				count++;
			}
			a+=2;
				//if (count % 10 == 0)
					//System.out.println();
			}
	}

	public static boolean isPrime(int p) {
		for (int i = 2; i < p; i++) {
			if (p % i == 0) {
				return false;
			}
		}
		return true;
	}

	public static boolean isEmirp(int x) {
		return isPrime(x) && isPrime(reverse(x)) && !isPalindrome(x);

	}
	public static boolean isPalindrome(int x){
		int n = x;
		int rev = 0;
		while(x>0){
			int dig = x%10;
			rev = rev*10+dig;
			x = x/10;
		}
		if(n==rev)
			return true;
		return false;
	}
	public static int reverse(int r) {
		if (r < 10)
			return r;
		return flipper(r % 10, r / 10);
	}

	public static int flipper(int a, int b) {
		if (b < 1)
			return a;
		return flipper(a * 10 + b % 10, b / 10);
	}

}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.Arrays;
import java.util.Collections;
import java.util.Scanner;
import java.util.Vector;

public class Main {

    /**
     * @param args
     * @throws IOException
     */
    public static void main(String[] args) throws IOException {
        // TODO Auto-generated method stub
        BufferedReader in=new BufferedReader(new InputStreamReader(System.in));
        //Scanner in=new Scanner(System.in);
        PrintWriter out=new PrintWriter(System.out);
        Vector<Long> smpl=new Vector<Long>();
        BigInteger cur=new BigInteger("13");
        int maxN=10000;
        for(int i=0; i<maxN; i++){
            smpl.add(cur.longValue());
            cur=cur.nextProbablePrime();
        }
        int n=Integer.parseInt(in.readLine());
        long[] mas=new long[n];
        mas[0]=13;
        int z=1;
        for(int i=0; i<smpl.size(); i++){
            if(z>=n) break;
            if(!smpl.contains(Long.parseLong(new StringBuffer(String.valueOf(smpl.elementAt(i))).reverse().toString()))){
                mas[z]=smpl.elementAt(i);
                z++;
            }
        }
        out.println(mas[n-1]);
        out.close();
    }

}


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

//4/1/12 7:54 PM
//by Abrackadabra

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

    int IOMode = 0; //0 - consoleIO, 1 - <taskName>.in/out, 2 - input.txt/output.txt, 3 - test case generator
    String taskName = "";

    String alpha = "абвгдеёжзийклмнопрстуфхцчшщъыьэюя";

    HashSet<Integer> getPrimes(int max) {
        boolean[] a = new boolean[max];
        HashSet<Integer> p = new HashSet<Integer>();
        for (int i = 2; i < max; i++) {
            if (a[i]) continue;
            for (int j = 2 * i; j < max; j += i) {
                a[j] = true;
            }
            p.add(i);
        }
        return p;
    }

    HashSet<Integer> primes = getPrimes(10000000);

    void solve() throws IOException {/*
        while (true) {
            String s = nextString();
            if (s == null) break;
            for (int j = 17; j <= 17; j++) {
                for (int i = 0; i < s.length(); i++) {
                    out.print(d(s.charAt(i), j));
                }
                out.println();
            }
        }
        for (int i = 'а'; i - 'а' < 33; i++)
            out.print((char)i);    */
        int n = nextInt();
        for (int i = 2; i < 1000000; i++) {
            if (primes.contains(i) && primes.contains(reverse(i)) && reverse(i) != i) {
                n--;
                if (n == 0) {
                    out.println(i);
                    break;
                }
            }
        }
    }

    int reverse(int x) {
        String s = Integer.toString(x);
        String t = "";
        for (int i = 0; i < s.length(); i++) {
            t = s.charAt(i) + t;
        }
        return Integer.parseInt(t);
    }

    char d(int x, int c) {
        String s = "" + (char) x;
        if (alpha.indexOf(s) < 0) {
            return (char) x;
        } else {
            return (char) alpha.charAt((alpha.indexOf(s) + c) % alpha.length());
        }
    }

    long startTime = System.nanoTime(), tempTime = startTime, finishTime = startTime;
    long startMem = Runtime.getRuntime().totalMemory(), finishMem = startMem;

    void run() throws IOException {
        init();
        if (debugMode) {
            con.println("Start");
            con.println("Console:");
        }
        solve();
        finishTime = System.nanoTime();
        finishMem = Runtime.getRuntime().totalMemory();
        out.flush();
        if (debugMode) {
            int maxSymbols = 1000;
            BufferedReader tbr = new BufferedReader(new FileReader("input.txt"));
            char[] a = new char[maxSymbols];
            tbr.read(a);
            if (a[0] != 0) {
                con.println("File input");
                con.println(a);
                if (a[maxSymbols - 1] != 0) con.println("...");
            }
            tbr = new BufferedReader(new FileReader("output.txt"));
            a = new char[maxSymbols];
            tbr.read(a);
            if (a[0] != 0) {
                con.println("File output");
                con.println(a);
                if (a[maxSymbols - 1] != 0) con.println("...");
            }
            con.println("Execution time: " + (finishTime - startTime) / 1000000000.0 + " sec");
            con.println("Used memory:    " + (finishMem - startMem) + " bytes");
            con.println("Total memory:   " + Runtime.getRuntime().totalMemory() + " bytes");
        }
    }

    boolean tick(double x) {
        if (System.nanoTime() - tempTime > x * 1e9) {
            tempTime = System.nanoTime();
            con.println("Tick at " + (tempTime - startTime) / 1000000000 + " sec");
            con.print("   ");
            return true;
        }
        return false;
    }

    static boolean debugMode = false;
    PrintStream con = System.out;

    void init() throws IOException {
        if (debugMode && IOMode != 3) {
            br = new BufferedReader(new FileReader("input.txt"));
            out = new PrintWriter(new FileWriter("output.txt"));
        } else
            switch (IOMode) {
                case 0:
                    br = new BufferedReader(new InputStreamReader(System.in));
                    out = new PrintWriter(System.out);
                    break;
                case 1:
                    br = new BufferedReader(new FileReader(taskName + ".in"));
                    out = new PrintWriter(new FileWriter(taskName + ".out"));
                    break;
                case 2:
                    br = new BufferedReader(new FileReader("input.txt"));
                    out = new PrintWriter(new FileWriter("output.txt"));
                    break;
                case 3:
                    out = new PrintWriter(new FileWriter("input.txt"));
                    break;
            }
    }

    BufferedReader br;
    PrintWriter out;
    StringTokenizer in;

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

    String nextString() throws IOException {
        return hasMoreTokens() ? in.nextToken() : null;
    }

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

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

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


public class MarsLandVaccine{
    public static void main(String[] args){
        long n = hp.nextLong();
        long x = hp.nextLong();
        long y = hp.nextLong();

        long k = hp.nextLong();

        long low = 0, high = 2 * n;

        while(low < high){
            long mid = (low + high) / 2;
            if(isValidTime(mid, n, k, x, y)){
                high = mid;
            }
            else{
                low = mid + 1;
            }

        }
        System.out.print(low);
    }

    public static boolean isValidTime(long days, long N, long k, long x, long y){

        long top = Math.max(0, (days - (x - 1)));
        long lft = Math.max(0, (days - (y - 1)));
        long rgt = Math.max(0, (y - (N - days)));
        long btm = Math.max(0, (x - (N - days)));

        long topLft = Math.max(0, (1 + d) - (x + y));
        long topRgt = Math.max(0, (1 + d) - (x + N - y + 1));
        long botLft = Math.max(0, (1 + d) - (y + N - x + 1));
        long botRgt = Math.max(0, (1 + d) - (N - x + 1 + N - y + 1));

        long answer = ((days * days) + ((days + 1) * (days + 1)));

        answer -= ((top * top) + (bot * bot) + (lft * left) + (rgt * rgt));

        answer += (topLft * (topLft + 1)) / 2;
        answer += (topRgt * (topRgt + 1)) / 2;
        answer += (botLft * (botLft + 1)) / 2;
        answer += (botRgt * (botRgt + 1)) / 2;

        return (answer >= k)
    }
}


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

public class bender {
    static int import java.io.*;
import java.util.*;

public class bender {
    static int n, x, y, c, t;

    public static void main(String[] args) throws NumberFormatException, IOException {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        //BufferedReader in = new BufferedReader(new FileReader("bender.in"));

        StringTokenizer nxyc = new StringTokenizer(in.readLine());
        n = Integer.parseInt(nxyc.nextToken());
        y = Integer.parseInt(nxyc.nextToken());
        x = Integer.parseInt(nxyc.nextToken());
        //int temp = x; y = temp; x = y;
        c = Integer.parseInt(nxyc.nextToken());
        t = c;

        int a = 0;
        int b = c;

        while (a <= b) {
            int tc = (a+b)/2;
            int total = 1;
            total += 4*tc;
            total += 4*inc(tc-1);

            int[] p = new int[]{x+tc-n, y+tc-n, 1+tc-x, 1+tc-y}; // x+, y+, x-, y-
            int[] q = new int[]{1+t-x-y, 1+t+x-y-n, x+y+t-2*n, y+t-n-x}; // 00 10 11 01

            for (int i = 0; i < 4; i++) if (p[i] > 0) total -= p[i]; else p[i] = 0;
            for (int i = 0; i < 4; i++) total -= 2*inc(p[i]-1);
            for (int i = 0; i < 4; i++) if (q[i] > 0) total += inc(q[i]);

            if (total >= c) {
                t = Math.min(tc, t);
                b = tc-1;
            } else {
                a = tc+1;
            }
        }

        System.out.println(t);
        System.exit(0);
    }

    public static int inc(int k) { // 1+2+3+...+k
        return (k*k+k)/2;
    }

    public static int dec(int total, int tc) {
        return 0;
    }
}


import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.PriorityQueue;
import java.util.Random;
import java.util.Scanner;
import java.util.Stack;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;
import java.lang.Long;

public class Test {
	static long mod = 1000000007;
	static int[][][][] dp;
	static boolean[][][][] check;
	static int contains;

	public static void main(String[] args) throws FileNotFoundException {
		PrintWriter out = new PrintWriter(System.out);
		Scanner in = new Scanner();
		int n = in.nextInt();
		int x = in.nextInt() - 1;
		int y = in.nextInt() - 1;
		long c = in.nextLong();
		int start = 0;
		int end = 2 * n;
		long result = end;
		while (start <= end) {
			int mid = (start + end) / 2;
			long total = 0;
			for (int i = Math.max(0, x - mid); i <= Math.min(n - 1, x + mid); i++) {
				int v = mid - Math.abs(i - x);
				long min = Math.max(0, y - v);
				long max = Math.min(n - 1, y + v);
				total += max - min + 1;

			}
			if(total < c){
				start = mid + 1;
			}else if(total >= c){
				result = Math.min(result, mid);
				end = mid - 1;
			}
		}
		out.println(result);

		out.close();
	}

	public static int dist(int index, String line) {
		int mul = 1;
		int result = 0;
		for (int i = index; i < line.length(); i++) {
			if (line.charAt(i) == 'T') {
				mul *= -1;
			} else {
				result += mul;
			}
		}
		return result;
	}

	static class Name implements Comparable<Name> {
		String name;
		int h;

		public Name(String name, int h) {
			super();
			this.name = name;
			this.h = h;
		}

		public int compareTo(Name o) {

			return h - o.h;
		}

	}

	static int find(int index, int[] u) {
		if (u[index] != index) {
			return u[index] = find(u[index], u);
		}
		return index;
	}

	static int crossProduct(Point a, Point b) {
		return a.x * b.y + a.y * b.x;
	}

	static long squareDist(Point a) {
		long x = a.x;
		long y = a.y;
		return x * x + y * y;
	}

	static Point minus(Point a, Point b) {
		return new Point(a.x - b.x, a.y - b.y);
	}

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

	static class Point {
		int x, y;

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

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

	}

	static class Entry implements Comparable<Entry> {
		int x, cost;

		public Entry(int x, int cost) {
			super();
			this.x = x;
			this.cost = cost;
		}

		public int compareTo(Entry o) {
			// TODO Auto-generated method stub
			if (cost > o.cost) {
				return 1;
			} else if (cost == o.cost) {
				return -1;
			}

			return 0;
		}
	}

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

	static class Scanner {

		BufferedReader br;
		StringTokenizer st;

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

		public String next() {

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

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

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

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

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

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


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

public class P255D {

  @SuppressWarnings("unchecked")
  public void run() throws Exception {
    long n = nextLong();
    long x = nextLong();
    long y = nextLong();
    long c = nextLong();

    if ((n == 1) || (c == 1)) {
      println(0);
      return;
    }

    x = Math.min(x, n - x + 1);
    y = Math.min(y, n - y + 1);
    long t = 0;
    long sum = 1;
    long add = 4;
    long subx1 = 3;
    long suby1 = 3;
    long subx2 = 3;
    long suby2 = 3;

    while (sum < c) {
      t++;

      sum += add;
      add += 4;

      if (t == x) {
        sum--;
      }
      if (t == n - x) {
        sum--;
      }
      if (t > x) {
        sum -= subx1;
        subx1 += 2;
      }
      if (t > n - x) {
        sum -= subx2;
        subx2 += 2;
      }

      if (t == y) {
        sum--;
      }
      if (t == n - y) {
        sum--;
      }
      if (t > y) {
        sum -= suby1;
        suby1 += 2;
      }
      if (t > n - y) {
        sum -= suby2;
        suby2 += 2;
      }

      if (t >= x + y) {
        sum += (t - x - y + 1);
      }

    }

    println(t);
  }

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

  static BufferedReader br;
  static PrintWriter pw;
  StringTokenizer stok;

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

  void print(byte b) { print("" + b); }
  void print(int i) { print("" + i); }
  void print(long l) { print("" + l); }
  void print(double d) { print("" + d); }
  void print(char c) { print("" + c); }
  void print(Object o) {
    if (o instanceof int[]) { print(Arrays.toString((int [])o));
    } else if (o instanceof long[]) { print(Arrays.toString((long [])o));
    } else if (o instanceof char[]) { print(Arrays.toString((char [])o));
    } else if (o instanceof byte[]) { print(Arrays.toString((byte [])o));
    } else if (o instanceof short[]) { print(Arrays.toString((short [])o));
    } else if (o instanceof boolean[]) { print(Arrays.toString((boolean [])o));
    } else if (o instanceof float[]) { print(Arrays.toString((float [])o));
    } else if (o instanceof double[]) { print(Arrays.toString((double [])o));
    } else if (o instanceof Object[]) { print(Arrays.toString((Object [])o));
    } else { print("" + o); }
  }
  void print(String s) { pw.print(s); }
  void println() { println(""); }
  void println(byte b) { println("" + b); }
  void println(int i) { println("" + i); }
  void println(long l) { println("" + l); }
  void println(double d) { println("" + d); }
  void println(char c) { println("" + c); }
  void println(Object o) { print(o); println(""); }
  void println(String s) { pw.println(s); }
  int nextInt() throws IOException { return Integer.parseInt(nextToken()); }
  long nextLong() throws IOException { return Long.parseLong(nextToken()); }
  double nextDouble() throws IOException { return Double.parseDouble(nextToken()); }
  char nextChar() throws IOException { return (char) (br.read()); }
  String next() throws IOException { return nextToken(); }
  String nextLine() throws IOException { return br.readLine(); }
  int [] readInt(int size) throws IOException {
    int [] array = new int [size];
    for (int i = 0; i < size; i++) { array[i] = nextInt(); }
    return array;
  }
  long [] readLong(int size) throws IOException {
    long [] array = new long [size];
    for (int i = 0; i < size; i++) { array[i] = nextLong(); }
    return array;
  }
  double [] readDouble(int size) throws IOException {
    double [] array = new double [size];
    for (int i = 0; i < size; i++) { array[i] = nextDouble(); }
    return array;
  }
  String [] readLines(int size) throws IOException {
    String [] array = new String [size];
    for (int i = 0; i < size; i++) { array[i] = nextLine(); }
    return array;
  }
}


import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner (System.in);
        String array;
        float x,y;
        Main test=new Main();
        line inst=test.new line();
        x= scanner.nextFloat();
        y= scanner.nextFloat();
        array=scanner.next();
        ArrayList<line> liness;
        liness=go(array);

        if(ifclosedpath(liness)==1)
              if( firstpath(x,y,liness)==1)
                {System.out.println("yes");
                return;
                }
            else
                {System.out.println("No");
                return;
                }

                if(firstpath(x,y,liness)==1)
                    System.out.println("yes");
                else
                    if(checkpoint(x,y,liness)>=0)
                        System.out.println("yes");

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

    }

static ArrayList<line> go(String array)
{
    int n=0;
   float x=0;
    float y=0;
    ArrayList<line> lines=new ArrayList<line>() ;
    Main test=new Main();
    line inst=test.new line();

      int l=array.length();

    while(n<l)
    {

        if(array.charAt(n)=='U')
        y=y+1;
        if(array.charAt(n)=='D')
        y=y-1;
        if(array.charAt(n)=='L')
        x=x-1;
        if(array.charAt(n)=='R')
        x=x+1;

        inst=new test.new line();
        inst.setX1(x);
        inst.setY1(y);
        lines.add(n,inst);

       n=n+1;

   }

    n=0;

    while(n<l)
    {

        if(array.charAt(n)=='U')
        y=y+1;
        if(array.charAt(n)=='D')
        y=y-1;
        if(array.charAt(n)=='L')
        x=x-1;
        if(array.charAt(n)=='R')
        x=x+1;

        inst=test.new line();
        inst=lines.get(n);

        inst.setX2(x);
        inst.setY2(y);

        lines.set(n, inst);

        n++;

    }

    for(int counter=0;counter<lines.size();counter++)
    {

        inst=test.new line();
        inst=lines.get(counter);
        inst.makeline();
        lines.set(counter, inst);

    }
    return lines;

}

static int firstpath(float x,float y,ArrayList <line> lines)
{
    Main test=new Main();
        line inst=test.new line();

    int l=lines.size();
    for (int counter=0;counter<l;counter++)
    {

        inst=test.new line();
        inst=lines.get(counter);
        if(x==inst.x1 && y==inst.y1 )
        return 1;

    }
    return 0;

}

static int checkpoint(float x,float y,ArrayList<line> lines)
{
    Main test=new Main();
        line inst=test.new line();

    float r;
    int flag=0;
    int counter;
    if(x==0 && y==0)
    return 0;

    else

    {

for(counter=0;counter<lines.size();counter++)
  {

    inst=test.new line();
    inst=lines.get(counter);
             if(inst.d=='v')
             {

                 if(x==inst.c)
                 {
                     flag++;
                     break;

                 }
             }
             else
                 if(inst.d=='h')
             {

                     if(y==inst.c)
                 {
                     flag++;
                     break;

                 }
             }
             else

      {

        r=inst.m*x;
        r=r+inst.c;

        if(y==r)
        {

            flag++;
            break;

        }

      }

}
    if(flag>0)
    return counter+1;
    else
    return -1;
    }

}

static int ifclosedpath(ArrayList <line> lines)
{

    if(lines.get(0).getX1()==lines.get(0).getX2() && lines.get(0).getY1()==lines.get(0).getY2() )
    return 1;
    else
        return 0;
}

public class line
{
    public float x1,x2,y1,y2,m,c;
    public char d;

    public void setX1(float x1) {
        this.x1 = x1;
    }

    public void setX2(float x2) {
        this.x2 = x2;
    }

    public void setY1(float y1) {
        this.y1 = y1;
    }

    public float getX2() {
        return x2;
    }

    public float getY2() {
        return y2;
    }

    public float getY1() {
        return y1;
    }

    public void setY2(float y2) {
        this.y2 = y2;
    }

    public float getX1() {
        return x1;
    }

    void makeline()
    {

        if(this.x1==this.x2)
        {
            this.d='v';
            this.c=this.x2;

        }
        else
            if(this.y1==this.y2)
            {
                this.d='h';
                this.c=this.y1;
            }
            else
            {
                this.d='n';
                this.m=(this.y2-this.y1)/(this.x2-this.x1);
                this.c=this.y1-(this.m*this.x1);

            }

    }

}

}


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

public class Contest190 {

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

    long a, b;
    long x = 0, y = 0;

    void step(char c) {
        switch(c) {
            case 'U': ++y; break;
            case 'D': --y; break;
            case 'L': --x; break;
            case 'R': ++x; break;
        }
    }

    boolean walk_path(String s) {
        for(int i = 0; i < s.length(); ++i) {
            if(x == a && y == b)
                return true;
            step(s.charAt(i));
        }
        return x == a && y == b;
    }

    int sign(int n) {
        return n < 0 ? -1 : (n == 0 ? 0 : 1);
    }

    void solve() throws IOException {
        a = nextInt();
        b = nextInt();
        String s = nextToken();
        if(walk_path(s)) {
            out.println("Yes");
            return;
        }
        if(x == 0 && y == 0) {
            out.println("No");
            return;
        }

        long steps = Integer.MAX_VALUE;
        if(x != 0 && && a / x != 0)
            steps = Math.max(steps, Math.abs(a / x));
        if(y != 0 && b / y != 0)
            steps = Math.max(steps, Math.abs(b / y));

        if(steps != Integer.MAX_VALUE) {
            x *= steps;
            y *= steps;
        }

        for(int i = 0; i < 500; ++i)
            if(walk_path(s)) {
                out.println("Yes");
                return;
            }
        out.println("No");
    }

    BufferedReader br;
    StringTokenizer st;
    PrintWriter out;

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

        return st.nextToken();
    }

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

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

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

    void run() throws IOException {
        boolean oj = System.getProperty("ONLINE_JUDGE") != null;

        br = new BufferedReader( new InputStreamReader( oj ? System.in : new FileInputStream("input.txt")));
        out = new PrintWriter( oj ? System.out : new FileOutputStream("output.txt"));

        solve();

        out.close();
    }

}


import java.util.*;
public class abc
{
    public static void main(String args[])
    {
        Scanner sc=new Scanner(System.in);
        long a=sc.nextLong();
        long b=sc.nextLong();
        if(a==0 && b==0)
        {
            System.out.print("YES");
            return;
        }
        sc.nextLine();
        String s=sc.nextLine();
        long x[][]=new long[s.length()][2];
        int m=0;
        int n=0;
        for(int i=0;i<s.length();i++)
        {
            char ch=s.charAt(i);
            switch(ch)
            {
                case 'U':n++;break;
                case 'D':n--;break;
                case 'L':m--;break;
                case 'R':m++;break;
                x[i][0]=m;
                x[i][1]=n;
            }
        }
        if(m!=0)
            a%=m;
        if(n!=0)
            b%=n;
        for(int i=0;i<s.length();i++)
        {
            if(a==x[i][0] && b==x[i][1])
            {
                System.out.print("YES");
                return;
            }
        }
        System.out.print("NO");
    }
}


import java.util.*;
public class abc
{
    public static void main(String args[])
    {
        Scanner sc=new Scanner(System.in);
        long a=sc.nextLong();
        long b=sc.nextLong();
        sc.nextLine();
        String s=sc.nextLine();
        long x[][]=new long[s.length()][2];
        int m=0;int n=0;
        for(int i=0;i<s.length();i++)
        {
            char ch=s.charAt(i);
            switch(ch)
            {
                case 'U':n++;break;
                case 'D':n--;break;
                case 'L':m--;break;
                case 'R':m++;break;
            }
            x[i][0]=m;
            x[i][1]=n;
        }
        if(a==0 && b==0)
        {
            System.out.print("Yes");
            return;
        }
        for(int i=0;i<s.length();i++)
        {
            long ta=a-x[i][0];
            long tb=b-x[i][1];
            if(m==0 && n==0 && ta==0 && tb==0)
            {
                System.out.print("Yes");
                return;
            }
            else if(m==0 && ta==0 && tb%n==0)
            {
                System.out.print("Yes");
                return;
            }
            else if(n==0 && tb==0 && ta%m==0)
            {
                System.out.print("Yes");
                return;
            }
            else(ta%m==0 && tb%n==0)
            {
                System.out.print("Yes");
                return;
            }
        }
        System.out.print("No");
    }
}


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

     Scanner read = new Scanner(System.in);
    int r;
    r = read.nextInt();
        if (r<1200)
            System.out.println(1200);
        if (r<1400)
            System.out.println(1400);
        if (r<1600)
            System.out.println(1600);
        if (r<1900)
            System.out.println(1900);
        if (r<2100)
            System.out.println(2100);
        if (r<2400)
            System.out.println(2400);
        if (r<2400)
            System.out.println(2400);
        if (r<2600)
            System.out.println(2600);
        else{
            System.out.println(3000);
        }

    }
}


import java.util.Scanner;
public class CheapTravel {

	public static void main(String[] args) {
	    Scanner scan = new Scanner(System.in)
	    int r = scan.nextInt();
	    System.out.println(r+1);

	}

}


import java.util.
public class Main {
    public static void main(String args[]) {
    Scanner read = new Scanner(System.in);
    int n = read.nextInt();
        if (n<1200)
            System.out.println(1200);
        if (n<1400)
            System.out.println(1400);
        if (n<1600)
            System.out.println(1600);
        if (n<1900)
            System.out.println(1900);
        if (n<2100)
            System.out.println(2100);
        if (n<2300)
            System.out.println(2300);
        if (n<2400)
            System.out.println(2400);
        if (n<2600)
            System.out.println(2600);
        else{
            System.out.println(3000);
        }

    }
}


import java.util.Scanner;
public class Main {
    public static void main(String args[]) {

     Scanner read = new Scanner(System.in);
    int n;
    r = read.nextInt();
        if (n<1200)
            System.out.println(1200);
        if (n<1400)
            System.out.println(1400);
        if (n<1600)
            System.out.println(1600);
        if (n<1900)
            System.out.println(1900);
        if (n<2100)
            System.out.println(2100);
        if (n<2400)
            System.out.println(2400);
        if (n<2600)
            System.out.println(2600);
        else{
            System.out.println(3000);
        }

    }
}


import java.util.*;

public class Sol{
	public static void main(String[] argc){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		int[] v = new int[n];
		for (int i = 0; i < n; ++i) v[i] = sc.nextInt();
		String s = sc.next();
		ArrayList<Integer> r = new ArrayList<>();
		ArrayList<Integer> w = new ArrayList<>();
		ArrayList<Integer> o = new ArrayList<>();
		for (int i = 0; i < n; i++) {
		    if (s.charAt(i) == 'R') {
		        r.add(v[i]);
		    } else if (s.charAt(i) == 'W') {
		        w.add(v[i]);
		    } else o.add(v[i]);
		}
		Collections.sort(r);
		Collections.sort(w);
		Collections.sort(o);
		int res = -1;
		if (k == 1) {
		    System.out.println(res);
		}
		else{
		if (!r.isEmpty() && !o.isEmpty() && r.size() + o.size() >= k) {
		    int t = o.get(o.size() - 1) + r.get(r.size() - 1);
		    ArrayList<Integer> al = new ArrayList<>();
		    for (int i = 0; i + 1 < r.size(); ++i)
		        al.add(r.get(i));
		    for (int i = 0; i + 1 < o.size(); ++i)
		        al.add(o.get(i));
		    Collections.sort(al);
		    for (int i = 0; i < k - 2; ++i) t += al.get(al.size() - 1 - i);
		    res = Math.max(res, t);
		}
		if (!w.isEmpty() && !o.isEmpty() && w.size() + o.size() >= k) {
		    int t = o.get(o.size() - 1) + w.get(w.size() - 1);
		    ArrayList<Integer> al = new ArrayList<>();
		    for (int i = 0; i + 1 < w.size(); ++i)
		        al.add(w.get(i));
		    for (int i = 0; i + 1 < o.size(); ++i)
		        al.add(o.get(i));
		    Collections.sort(al);
		    for (int i = 0; i < k - 2;++i) t += al.get(al.size() - 1 - i);
		    res = Math.max(res, t);
		}
		System.out.println(res);
		}
	}
}


import java.util.*;
public class Task {

    public static long max(long a, long b ) {
        if(a < b) {
            return b;
        }
        return a;
    }

    public static int max(int a, int b ) {
        if(a < b) {
            return b;
        }
        return a;
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int[] beauty = new int[200005];
        for(int i = 0; i < n; i++) {
            beauty[i] = sc.nextInt();
        }
        sc.nextLine();
        String str = sc.nextLine();
        int rcn = 0;
        int wcn = 0;
        int ocn = 0;
        int rsum = 0;
        int wsum = 0;
        int osum = 0;
        ArrayList<Integer> wo = new ArrayList<Integer>();
        ArrayList<Integer> ro = new ArrayList<Integer>();
        int maxo = -1;
        int maxr = -1;
        int maxw = -1;
        for(int i = 0; i < n; i++) {
            if(str.charAt(i) == 'R') {
                maxr = max(maxr,beauty[i]);
                rcn++;
                ro.add(beauty[i]);
                rsum+= beauty[i];
            }
            if(str.charAt(i) == 'W') {
                maxw = max(maxw,beauty[i]);
                wcn++;
                wo.add(beauty[i]);
                wsum+= beauty[i];
            }
            if(str.charAt(i) == 'O') {
                maxo = max(maxo,beauty[i]);
                ocn++;
                ro.add(beauty[i]);
                wo.add(beauty[i]);
                osum+= beauty[i];
            }
        }
        if(k == 1 || ocn == 0 || max(ocn+wcn,ocn+rcn) < k || (rcn == 0 && wcn == 0)) {
            System.out.print(-1);
        } else {
            if(rcn > 0) {
                ro.remove(ro.indexOf(maxr));
            }
            ro.remove(ro.indexOf(maxo));
            if(wcn > 0) {
                wo.remove(wo.indexOf(maxw));
            }
            wo.remove(wo.indexOf(maxo));
            Collections.sort(ro);
            Collections.sort(wo);
            long ans1 = maxr+maxo;
            long ans2 = maxw+maxo;
            if(ro.size()+2 >= k) {
                for(int i = ro.size()-1; i >= ro.size()-k+2; i--) {
                    ans1+= ro.get(i);
                }
            }
            if(wo.size()+2 >= k) {
                for(int i = wo.size()-1; i >= wo.size()-k+2; i--) {
                    ans2+= wo.get(i);
                }
            }
            System.out.print(max(ans1,ans2));
        }
    }
}


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

public class temp
{
    public static void main(String args[])
    {
        Scanner in=new Scanner(System.in);
        int n=in.nextInt();
        int k=in.nextInt();
        int[] b=new int[n];
        for(int i=0;i<n;i++)
            b[i]=in.nextInt();
        char[] t=in.next().toCharArray();
        ArrayList<Integer> w=new ArrayList<Integer>();
        ArrayList<Integer> o=new ArrayList<Integer>();
        ArrayList<Integer> r=new ArrayList<Integer>();
        for(int i=0;i<n;i++)
        {
            if(t[i]=='R')
                r.add(b[i]);
            else if(t[i]=='O')
                o.add(b[i]);
            else
                w.add(b[i]);
        }
        Collections.sort(w);
        Collections.sort(o);
        Collections.sort(r);
        int sumw[]=new int[w.size()+1];
        int sumr[]=new int[r.size()+1];
        sumw[0]=0;
        sumr[0]=0;
        for(int i=0;i<w.size();i++)
            sumw[i+1]=sumw[i]+w.get(w.size()-i-1);
        for(int i=0;i<r.size();i++)
            sumr[i+1]=sumr[i]+r.get(r.size()-i-1);
        int res=-1;
        int co=0;
        for(int i=0;i<=o.size() && i<k;i++)
        {
            if(i!=0){
            if(k-i<sumw.length)
                res=Math.max(res, co+sumw[k-i]);
            if(k-i<sumr.length)
                res=Math.max(res, co+sumr[k-i]);
            }
            if(i<o.size())
                co=co+o.get(o.size()-1-i);
        }
        System.out.println(res);
    }
}


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

public class temp
{
    public static void main(String args[])
    {
        Scanner in=new Scanner(System.in);
        int n=in.nextInt();
        int k=in.nextInt();
        int[] b=new int[n];
        for(int i=0;i<n;i++)
            b[i]=in.nextInt();
        char[] t=in.next().toCharArray();
        ArrayList<Integer> w=new ArrayList<Integer>();
        ArrayList<Integer> o=new ArrayList<Integer>();
        ArrayList<Integer> r=new ArrayList<Integer>();
        for(int i=0;i<n;i++)
        {
            if(t[i]=='R')
                r.add(b[i]);
            else if(t[i]=='O')
                o.add(b[i]);
            else
                w.add(b[i]);
        }
        Collections.sort(w);
        Collections.sort(o);
        Collections.sort(r);
        int s[]=new int[w.size()+1];
        int ss[]=new int[r.size()+1];
        s[0]=0;
        ss[0]=0;
        for(int i=0;i<w.size();i++)
            s[i+1]=s[i]+w.get(w.size()-i-1);
        for(int i=0;i<r.size();i++)
            ss[i+1]=ss[i]+r.get(r.size()-i-1);
        int res=-1;
        int co=0;
        for(int i=0;i<=o.size() && i<k;i++)
        {
            if(i!=0){
            if(k-i<s.length)
                res=Math.max(res, co+s[k-i]);
            if(k-i<sumr.length)
                res=Math.max(res, co+ss[k-i]);
            }
            if(i<o.size())
                co=co+o.get(o.size()-1-i);
        }
        System.out.println(res);
    }
}


import java.io.*;
import java.util.*;
import static java.lang.System.*;
import static java.lang.Math.*;
public class Code
{
    int P1,P2,T1,T2,H,S;
    void run() {
        int tc=1;
        StringBuilder sb=new StringBuilder();
        while(tc-->0) {
            P1=ni(); T1=ni();
            P2=ni(); T2=ni();
            H=ni(); S=ni();
            if(T1>T2) {
                P1^=P2^(P2=P1);
                T1^=T2^(T2=T1);
            }
            // dp = new Integer[H+1];
            dp = new HashMap<>();
            int ans = solve(P1, T1, P2, T2, H, S, 0);
            sb.append(ans).append("\n");
        }
        out.println(sb);
        out.flush();
        out.close();
    }
    Integer x = Integer.MAX_VALUE;
    Map<String, Integer> dp;
    int solve(int p1, int t1, int p2, int t2, int h, int s, int c) {
        if(h<=0) return 0;

        // int diff=Math.abs(c1-c2);
        String str = concat(h, t1, t2);
        if(dp.containsKey(str)) return dp.get(str);
        // 5000*5000=2.5*10^7

        int res = 0;
        if(t1+T1<=t2) {
            res = t1+solve(p1, T1, p2, t2-t1, h-(p1-s), s, c+t1);
        }
        else if(t1>t2) {
            int x = t1+solve(p1, T1, p2, T2, h-(p1+p2-s), s, c+t1);
            int y = t2+solve(p1, t1-t2, p2, T2, h-(p2-s), s, c+t2);
            res = min(x,y);
        }
        else {
            int x = t1+solve(p1, T1, p2, t2-t1, h-(p1-s), s, c+t1);
            int y = t2+solve(p1, T1, p2, T2, h-(p1+p2-s), s, c+t2);
            // System.out.println(h+" "+x+" "+y);
            res = min(x,y);
        }
        dp.put(str, res);
        return res;

    }
    String concat(Integer... v) {
        StringBuilder sb = new StringBuilder();
        for(Integer i: v) sb.append(i).append(" ");
        return sb.toString();
    }
    StringBuilder pr(String s, int t) {
        return new StringBuilder().append("Case #").append(t).append(": ").append(s).append("\n");
    }
    public static void main(String[] args)throws Exception {
        try {
            // new Thread(null, new Code()::run, "1", 1 << 26).start();
            new Thread(null, new Code("ONLINE_JUDGE")::run, "1", 1 << 26).start();
        } catch(Exception e) {}
    }

    FastReader sc=null;PrintWriter out = null;
    public Code()throws Exception {
        sc = new FastReader(new FileInputStream("input.txt"));
        out = new PrintWriter(new BufferedWriter(new FileWriter("output.txt")));
    }
    public Code(String JUDGE) {
        sc = new FastReader(System.in);
        out = new PrintWriter(System.out);
    }

    String ns() { return sc.next(); }
    int ni() { return sc.nextInt(); }
    long nl() { return sc.nextLong(); }
    int[] ni(int n) {
        int a[]=new int[n];
        for(int i=0;i<n;a[i++]=ni());
        return a;
    }
    long[] nl(int n) {
        long a[]=new long[n];
        for(int i=0;i<n;a[i++]=nl());
        return a;
    }

    int[][] ni(int n,int m) {
        int a[][]=new int[n][m];
        for(int i=0;i<n;i++)
            for(int j=0;j<m;j++)
                a[i][j]=ni();
        return a;
    }
    long[][] nl(int n,int m) {
        long a[][]=new long[n][m];
        for(int i=0;i<n;i++)
            for(int j=0;j<m;j++)
                a[i][j]=nl();
        return a;
    }
    int gcd(int a, int b) {
        return b==0?a:gcd(b,a%b);
    }
    static class FastReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private FastReader.SpaceCharFilter filter;
        public FastReader(InputStream stream) {
            this.stream = stream;
        }

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

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

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

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

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

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

        }
    }
}


import java.io.*;
import java.util.*;
import static java.lang.System.*;
import static java.lang.Math.*;
public class Code
{
    int P1,P2,H,S;
    long T1,T2;
    void run() {
        int tc=1;
        StringBuilder sb=new StringBuilder();
        while(tc-->0) {
            P1=ni(); T1=nl();
            P2=ni(); T2=nl();
            H=ni(); S=ni();
            if(T1>T2) {
                P1^=P2^(P2=P1);
                T1^=T2^(T2=T1);
            }
            // dp = new Integer[H+1];
            dp = new HashMap<>();
            long ans = solve(P1, T1, P2, T2, H, S);
            sb.append(ans).append("\n");
        }
        out.println(sb);
        out.flush();
        out.close();
    }
    Map<String, Long> dp;
    long solve(int p1, long t1, int p2, long t2, long h, int s) {
        if(h<=0) return 0L;

        // int diff=Math.abs(c1-c2);
        String str = concat(h, t1, t2);
        if(dp.containsKey(str)) return dp.get(str);
        // 5000*5000=2.5*10^7

        long res = 0;
        if(t1+T1<=t2) {
            res = t1+solve(p1, T1, p2, t2-t1, h-(p1-s), s);
        }
        else if(t1>t2) {
            long x = t1+solve(p1, T1, p2, T2, h-(p1+p2-s), s);
            long y = t2+solve(p1, t1-t2, p2, T2, h-(p2-s), s);
            res = min(x,y);
        }
        else {
            long x = t1+solve(p1, T1, p2, t2-t1, h-(p1-s), s);
            long y = t2+solve(p1, T1, p2, T2, h-(p1+p2-s), s);
            // System.out.println(h+" "+x+" "+y);
            res = min(x,y);
        }
        dp.put(str, res);
        return res;

    }
    String concat(Long... v) {
        StringBuilder sb = new StringBuilder();
        for(Long i: v) sb.append(i).append(" ");
        return sb.toString();
    }
    StringBuilder pr(String s, int t) {
        return new StringBuilder().append("Case #").append(t).append(": ").append(s).append("\n");
    }
    public static void main(String[] args)throws Exception {
        try {
            // new Thread(null, new Code()::run, "1", 1 << 26).start();
            new Thread(null, new Code("ONLINE_JUDGE")::run, "1", 1 << 26).start();
        } catch(Exception e) {}
    }

    FastReader sc=null;PrintWriter out = null;
    public Code()throws Exception {
        sc = new FastReader(new FileInputStream("input.txt"));
        out = new PrintWriter(new BufferedWriter(new FileWriter("output.txt")));
    }
    public Code(String JUDGE) {
        sc = new FastReader(System.in);
        out = new PrintWriter(System.out);
    }

    String ns() { return sc.next(); }
    int ni() { return sc.nextInt(); }
    long nl() { return sc.nextLong(); }
    int[] ni(int n) {
        int a[]=new int[n];
        for(int i=0;i<n;a[i++]=ni());
        return a;
    }
    long[] nl(int n) {
        long a[]=new long[n];
        for(int i=0;i<n;a[i++]=nl());
        return a;
    }

    int[][] ni(int n,int m) {
        int a[][]=new int[n][m];
        for(int i=0;i<n;i++)
            for(int j=0;j<m;j++)
                a[i][j]=ni();
        return a;
    }
    long[][] nl(int n,int m) {
        long a[][]=new long[n][m];
        for(int i=0;i<n;i++)
            for(int j=0;j<m;j++)
                a[i][j]=nl();
        return a;
    }
    int gcd(int a, int b) {
        return b==0?a:gcd(b,a%b);
    }
    static class FastReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private FastReader.SpaceCharFilter filter;
        public FastReader(InputStream stream) {
            this.stream = stream;
        }

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

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

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

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

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

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

        }
    }
}


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

public class E {

	static IOHandler sc = new IOHandler();

	static Long [] memo;

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

	private static void solve(int t) {
		long p1 = sc.nextInt();
		long t1 = sc.nextLong();

		long p2 = sc.nextInt();
		long t2 = sc.nextLong();

		long h = sc.nextInt();
		long s = sc.nextInt();

		memo = new Long [(int)h + 1];

		long minP, minT, maxP, maxT;

		if (t1 < t2) {
			minP = p1;
			minT = t1;
			maxP = p2;
			maxT = t2;
		}else {
			minP = p2;
			minT = t2;
			maxP = p1;
			maxT = t1;
		}

		long res = solve(minP, minT, maxP, maxT, h, s);

		System.out.println(res);
	}

	private static long solve(long p1, long t1, long p2, long t2, long h, long s) {

		if (h <= 0)
			return 0;
		else if (h <= p1 - s) {
			return t1;
		}else if (memo[(int)h] != null) {
			return memo[(int)h];
		}

		long result = Long.MAX_VALUE;
		long test;

		long end, val;
		long count;

		for (int i = 1; (i - 1) * (p1 - s) <= h ; ++i) {
			end = i * t1;
			val = (p1-s)*i;
			test = val;

			if (end >= t2) {
				count = (end - t2)/ t2;
				val = count * (p2 - s);
				val += p2;
				test += val;
			}
			end += solve(p1, t1, p2, t2, h - test, s);

			result = Math.min(result, end);
		}

		for (int i = 1; (i - 1) * (p2 - s) <= h ; ++i) {
			end = i * t2;

			val = (p2 - s ) * i;
			test = val;

			if (end >= t1) {
				count = (end - t1)/ t1;
				val = count * (p1 - s);
				val += p1;
				test += val;
			}

			end += solve(p1, t1, p2, t2, h - test, s);

			result = Math.min(result, end);
		}

		return result;
	}

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

		return gcd(b , a % b);
	}

	private static class IOHandler {
      BufferedReader br;
      StringTokenizer st;

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

      int [] readArray(int n) {
    	  int [] res = new int [n];

    	  for (int i = 0; i < n; ++i)
    		  res[i] = nextInt();

    	  return res;
      }

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

   }

}


// package c1743;

//
// Educational Codeforces Round 137 (Rated for Div. 2) 2022-10-17 07:35
// E. FTL
// https://codeforces.com/contest/1743/problem/E
// time limit per test 4 seconds; memory limit per test 512 megabytes
// public class Pseudo for 'Source should satisfy regex [^{}]*public\s+(final)?\s*class\s+(\w+).*'
//
// Monocarp is playing a video game. In the game, he controls a spaceship and has to destroy an
// enemy spaceship.
//
// Monocarp has two lasers installed on his spaceship. Both lasers 1 and 2 have two values:
//  * p_i-- the power of the laser;
//  * t_i-- the reload time of the laser.
//
// When a laser is fully charged, Monocarp can either shoot it or wait for the other laser to charge
// and shoot both of them at the same time.
//
// An enemy spaceship has h durability and s shield capacity. When Monocarp shoots an enemy
// spaceship, it receives (P - s) damage (i.?e. (P - s) gets subtracted from its durability), where
// P is the total power of the lasers that Monocarp shoots (i.?e. p_i if he only shoots laser i and
// p_1 + p_2 if he shoots both lasers at the same time). An enemy spaceship is considered destroyed
// when its durability becomes 0 or lower.
//
// Initially, both lasers are zero charged.
//
// What's the lowest amount of time it can take Monocarp to destroy an enemy spaceship?
//
// Input
//
// The first line contains two integers p_1 and t_1 (2 <= p_1 <= 5000; 1 <= t_1 <= 10^{12})-- the
// power and the reload time of the first laser.
//
// The second line contains two integers p_2 and t_2 (2 <= p_2 <= 5000; 1 <= t_2 <= 10^{12})-- the
// power and the reload time of the second laser.
//
// The third line contains two integers h and s (1 <= h <= 5000; 1 <= s < \min(p_1, p_2))-- the
// durability and the shield capacity of an enemy spaceship. Note that the last constraint implies
// that Monocarp will always be able to destroy an enemy spaceship.
//
// Output
//
// Print a single integer-- the lowest amount of time it can take Monocarp to destroy an enemy
// spaceship.
//
// Example
/*
input:
5 10
4 9
16 1
output:
20

input:
10 1
5000 100000
25 9
output:
25
*/
// Note
//
// In the first example, Monocarp waits for both lasers to charge, then shoots both lasers at 10,
// they deal (5 + 4 - 1) = 8 damage. Then he waits again and shoots lasers at 20, dealing 8 more
// damage.
//
// In the second example, Monocarp doesn't wait for the second laser to charge. He just shoots the
// first laser 25 times, dealing (10 - 9) = 1 damage each time.
//

import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStreamReader;
import java.lang.invoke.MethodHandles;
import java.util.Arrays;
import java.util.Random;
import java.util.StringTokenizer;

public class C1743E {
  static final int MOD = 998244353;
  static final Random RAND = new Random();

  static long solve(long[][] lasers, int h, int s) {
    Arrays.sort(lasers, (x ,y) -> Long.compare(x[1], y[1]));
    int p1 = (int) lasers[0][0];
    long t1 = lasers[0][1];
    int p2 = (int) lasers[1][0];
    long t2 = lasers[1][1];
    long g = gcd(t1, t2);
    if (g > 1) {
      t1 /= g;
      t2 /= g;
    }
    myAssert(t1 <= t2);

    long maxt = Math.max(t1, t2);
    int sump = p1 + p2;
    int round = (h + sump - 1) / sump;
    long ans = round * maxt;
    if (t1 == t2) {
      return round * maxt * g;
    }

    // t2 is full multiple of t1
    if (t2 % t1 == 0) {
      // damage within each period of t2
      long m = t2 / t1;
      long d = (m-1) * (p1 - s) + (p1 + p2 - s);
      int k = (int) (h / d);
      int r = (int) (h - k * d);
      int l = r / (p1 - s);
      ans = k * t2 + (l < m ? l * t1 : t2);
      return ans * g;
    }

    {
      int r = (h + p1 - s - 1) / (p1 - s);
      if (r * t1 <= t2) {
        return r * t1 * g;
      }
    }

    // dp[v] is lowest amount of time to destroy spaceship with v durability
    long[] dp = new long[h + 1];
    Arrays.fill(dp, (long) 1e16);
    for (int v = 1; v <= h; v++) {
      // simulation: consider time t where t is multiple of t1 or t2
      int r = v;
      long x1 = t1;
      long x2 = t2;
      int d1 = p1 - s;
      int d2 = p2 - s;
      int d = p1 + p2 - s;
      while (true) {
        if (x1 < x2) {
          // t1 arrives first
          if (d1 >= r) {
            dp[v] = Math.min(dp[v], x1);
            break;
          }
          if (x1 + t1 <= x2) {
            // need apply the damage at x1 (no wait)
            r -= d1;
          } else {
            // two choices:
            //  1. wait until x2 and apply both damage
            //  2. apply the damage at x1 (no wait)
            if (d >= r) {
              dp[v] = Math.min(dp[v], x2);
            } else {
              dp[v] = Math.min(dp[v], x2 + dp[r - d]);
            }
            r -= d1;
          }
          x1 += t1;
        } else if (x1 == x2) {
          // t1 and t2 arrive at same time, apply both damage
          if (d >= r) {
            dp[v] = Math.min(dp[v], x2);
          } else {
            dp[v] = Math.min(dp[v], x2 + dp[r - d]);
          }
          // Completed a full cycle, done for v due to DP.
          break;
        } else {
          // t2 arrives first
          if (d2 >= r) {
            dp[v] = Math.min(dp[v], x2);
            break;
          }
          myAssert(x2 + t2 > x1);
          // two choices:
          //  1. wait until x1 and apply both damage
          //  2. apply the damage at x2 (no wait)
          if (d >= r) {
            dp[v] = Math.min(dp[v], x1);
          } else {
            dp[v] = Math.min(dp[v], x1 + dp[r - d]);
          }
          r -= d2;
          x2 += t2;
        }
      }
    }
    return dp[h] * g;
  }

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

  static void test(long exp, long[][] lasers, int h, int s) {
    long ans = solve(lasers, h, s);
    System.out.format("%s %d %d => %d\n", Arrays.deepToString(lasers), h, s, ans, ans == exp ? "":"Expected " + exp);
    myAssert(ans == exp);
  }

  static boolean test = false;
  static void doTest() {
    if (!test) {
      return;
    }
    long t0 = System.currentTimeMillis();
    test(259, new long[][] {{2,49},{2,21}}, 21, 1);

    test(20, new long[][] {{5,10},{4,9}}, 16, 1);
    test(25, new long[][] {{10,1},{5000,100000}}, 25, 9);
    test(67, new long[][] {{3,19},{4,29}}, 11, 2);
    System.out.format("%d msec\n", System.currentTimeMillis() - t0);
    System.exit(0);
  }

  public static void main(String[] args) {
    doTest();
    MyScanner in = new MyScanner();
    long[][] lasers = new long[2][2];
    for (int i = 0; i < 2; i++) {
      lasers[i][0] = in.nextInt();
      lasers[i][1] = in.nextInt();
    }
    int h = in.nextInt();
    int s = in.nextInt();
    long ans = solve(lasers, h, s);
    System.out.println(ans);
  }

  static void output(int[] a) {
    if (a == null) {
      System.out.println("-1");
      return;
    }
    StringBuilder sb = new StringBuilder();
    for (int v : a) {
      sb.append(v);
      sb.append(' ');
      if (sb.length() > 4000) {
        System.out.print(sb.toString());
        sb.setLength(0);
      }
    }
    System.out.println(sb.toString());
  }

  static void myAssert(boolean cond) {
    if (!cond) {
      throw new RuntimeException("Unexpected");
    }
  }

  static class MyScanner {
    BufferedReader br;
    StringTokenizer st;

    public MyScanner() {
      try {
        final String USERDIR = System.getProperty("user.dir");
        String cname = MethodHandles.lookup().lookupClass().getCanonicalName().replace(".MyScanner", "");
        cname = cname.lastIndexOf('.') > 0 ? cname.substring(cname.lastIndexOf('.') + 1) : cname;
        final File fin = new File(USERDIR + "/io/c" + cname.substring(1,5) + "/" + cname + ".in");
        br = new BufferedReader(new InputStreamReader(fin.exists()
            ? new FileInputStream(fin) : System.in));
      } catch (Exception e) {
        br = new BufferedReader(new InputStreamReader(System.in));
      }
    }

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

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

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


import java.util.*;

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

		int a;
		number = kb.nextInt();

		a = a % 10;

		if (a > 5) {
			a = a - (n%10)+10;
		} else {
			a = a - (n%10);
			System.out.println(a);
		}
	}
}


import java.util.*;
import java.util.Scanner;
public class S {
    public static int round (n) {
      Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      m = n
      //m = 1's place
      while (m > 1000) {
          m = m - 1000;
      }
      while (m > 100) {
          m = m - 100;
      }
      while ( m > 10) {
          m = m - 10;
      }
      zeroDist = m;
      tenDist = 10 - m;
      if (zeroDist < tenDist) {
          n = n - zeroDist;
      } else {
          n = n + tenDist;
      }
      return n;
    }
}


import java.util.*;

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

		int a;
		number = kb.nextInt();

		a = a % 10;

		if (a > 5) {
			a = a - (a%10)+10;
		} else{
			a = a - (a%10);
			System.out.println(a);
		}
	}
}


import java.util.*;

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

		int a;
		int b;
		a = kb.nextInt();

		b = a % 10;

		if (b > 5) {
			a - b;
		} else {
			a + (10 - b);
			System.out.println(a);
		}
	}
}


package hw1;

import java.util.Scanner;

public class Square {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);
		int d = scan.nextInt();
		int x = scan.nextInt();
		int y = scan.nextInt();
		if(x == (d+1)/2 || x-1 == (d+1)/2 || y== (d+1)/2 || y-1 ==(d+1)/2) {
			System.out.println("NO");
		}else {
			System.out.println("YES");
		}
	}

}


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

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

    StreamTokenizer in;
    PrintWriter out;

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) throws Exception {
        new Main().run();
    }

    public void run() throws Exception {
        in = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));
        out = new PrintWriter(new OutputStreamWriter(System.out));
        solve();
        out.flush();
    }

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

    public void solve() throws Exception {
        int n=nextInt();
        int x=nextInt();
        int y=nextInt();
        if (n<=2) out.println("NO");
        else{
          int a=n/2;
          if((x==a)&&(y==a)||(x==a)&&(y==a+1)||(x==a+1)&&(y==a)||(x==a+1)&&(y==a+1))out.println("NO");
          else out.println("YES");
        }
    }