Problem: ICPC World Finals Day 2

Mr. Tee and his colleagues arrived at the airport terminal. From now on, I will transfer the plane and board the enemy land R country. Since we go through Country D, we have to exchange our money into two currencies.

Mr. Kay "How does Mr. Tee exchange money?"

Mr. Tee "Huff Huff Huff Huff Huff Huff Huff Huff"

Mr. Kay "I see. I will allocate 20,000 yen for country D and 5,000 yen for country R."

Mr. Tee "Huff Huff Huff Huff Huff Huff Huff Huff"

Mr. Kay "That's strange. The exchange result is different from mine ..."

problem

One traveler is thinking of leaving Japan, sightseeing in country D (currency unit D) and country R (currency unit R), and returning to Japan. I have a \\ (M \\) yen now. I know that \\ (c_ {D} \\) [D] and \\ (c_ {R} \\) [R] will be consumed in each country, so I want to exchange money so that I don't run out of money. \\ (x \\) If you exchange yen for D country money, \\ (\ lfloa \ frac {r_ {D} x} {100} \ rfloor \\) [D], \\ (x \\) If you exchange yen for R country money, it becomes \\ (\ lfloa \ frac {r_ {R} x} {100} \ rfloor \\) [R].

For example, if you exchange 150 yen for D country money at \\ (r_ {D} = 11, c_ {D} = 10 \\), \\ (\ lfloor \ frac {11 \ times 150} {100} \ rfloor = \\) 16 [D] so there is no shortage of money. However, if you exchange only 50 yen, it will be 5 [D] and less than 10 [D], so you will run out of money.

Also, when returning to Japan, all the money on hand will be exchanged for Japanese yen. If you exchange \\ (x \\) [D] for Japanese Yen, you will get \\ (\ lfloor \ frac {100x} {r_ {D}} \ rfloor \\) Yen, \\ (x \\) [R] Is converted into Japanese Yen, which becomes \\ (\ lfloor \ frac {100x} {r_ {R}} \ rfloor \\) Yen.

In the first example above, 10 [D] of the obtained 16 [D] are consumed, so 6 [D] is left over. If you exchange this for Japanese Yen, it will be \\ (\ lfloor \ frac {100 \ times 6} {11} \ rfloor = 54 \\) Yen.

Find the maximum amount of Japanese Yen that will eventually be returned to you when you return to Japan when you have optimally exchanged Japanese Yen at the time of departure. No matter what kind of exchange you make, if you run out of money in either Country D or Country R, ​​output "-1".

* \\ (\ lfloor x \ rfloor \\) represents the largest integer that does not exceed \\ (x \\).

input


M rD rR cD cR


The first line is the amount of Japanese Yen you currently have \\ (M \\), the exchange rate between Japanese Yen and the currency unit of Country D \\ (r_ {D} \\), the currency unit of Japanese Yen and Country R Exchange rate with \\ (r_ {R} \\), money consumption in country D \\ (c_ {D} \\), money consumption in country R \\ (c_ {R} \ \) Is given separated by spaces.

output

Output the maximum amount of Japanese Yen that will be returned to you on one line. No matter what kind of exchange you make, if you run out of money in either Country D or Country R, ​​output "-1".

Constraint

* \\ (0 \ leq M \ leq 10 ^ {12} (= 1000000000000) \\)
* \\ (1 \ leq r_ {D}, r_ {R} \ leq 100 \\)
* \\ (0 \ leq c_ {D}, c_ {R} \ leq 10 ^ {12} (= 1000000000000) \\)


Input / output example

Input 1


20000 3 1 20 100


Output 1


9333


If you convert 667 yen to country D money and 10,000 yen to country R money, you will get 20 [D] and 100 [R], respectively.

Input 2


1000000000000 3 1 20 100


Output 2


999999989333


This traveler is very rich.

Input 3


0 3 1 20 100


Output 3


-1


This traveler is sentenceless and can't go anywhere.





Example

Input

M r


Output

9333

Solution (in CPP):

Solution:
#include<iostream>
#include<cmath>
#include<algorithm>
#include<deque>
#include<stack>
#include<queue>
#include<sstream>
#include<cstdlib>
#define INF 16777216
typedef long long llong;
using namespace std;
deque<int>deq;
int init();
int dfs();
int s2i(string);
string i2s(int);
llong EN2D(llong,llong);
llong EN2R(llong,llong);
llong D2EN(llong,llong);
llong R2EN(llong,llong);
//
int n,tmp,flg,mx,mn,num,sum,i,j,k,H,W,avg;
int main(){
  llong M,Cd,Cr,MD,MR,RA,DA;
  int rD,rR;
  cin >> M >> rD >> rR >> Cd >> Cr;
  
  MD=D2EN(Cd,rD);
  MR=R2EN(Cr,rR);
  if(M<MD+MR){
    cout<<-1<<endl;
  }else{
    // cout<<MD<<" is MD"<<endl;
    // cout<<MR<<" is MR"<<endl;
    DA=D2EN( EN2D(10000,rD),rD);
    RA=R2EN( EN2R(10000,rR),rR);
    if(DA>RA ){
      if(DA>10000){
	//Rで最小限 Dで残りぜんぶ
	MD=M-MR;
	
	MD=D2EN(EN2D(MD,rD),rD);
	MR=R2EN(EN2R(MR,rR),rR);
	cout<<MR+MD<<endl;
	return 0;
      }
      
      
    }else{
      if(RA>10000){
      //Dで最小限 Rで残りぜんぶ
	MR=M-MD;
	
	MD=D2EN(EN2D(MD,rD),rD);
	MR=R2EN(EN2R(MR,rR),rR);
	cout<<MR+MD<<endl;
	return 0;
      }
    }
    
    cout<<M-MD-MR<<endl;
  }

  return 0;
}

llong EN2D(llong x,llong rD){
  return (rD*x)/100 + ((rD*x)%100>0);
}
llong EN2R(llong x,llong rR){
  return (rR*x)/100 + ((rR*x)%100>0);
}
llong D2EN(llong x,llong rD){
  return (100*x)/rD + ((100*x)%rD>0);
}
llong R2EN(llong x,llong rR){
  return (100*x)/rR + ((100*x)%rR>0);
}


int init(){
}
int dfs(){
}


int s2i(string str){
  int num;
  num=atoi(str.c_str());
  return num;
}

string i2s(int num){
  string str;
  stringstream s;
  s<<num;
  s>>str;
  return str;
}