#include <iostream>
#include <fstream>
#include <algorithm>
using namespace std;
int Coins[6];
int CoinNum = 0;
int Pay;
int CoinValue[6] = {5, 10, 20, 50, 100, 200};
int ChangeValue[7] = {0, 5, 10, 20, 50, 100, 200};
int RealMoney = CoinValue[0] - ChangeValue[0];
void getData()
{
for (int i = 0; i < 6; ++i)
cin>> Coins[i];
double costt;
cin >> costt;
Pay = (int)(costt * 100);
}
void outputResult()
{
if (CoinNum == 0 || Pay != 0)
{
cout<< "impossible" << endl;
}
else
{
cout<< CoinNum << endl;
}
}
int contains(int a)
{
for (int i = 0; i < 6; ++i)
if (CoinValue[i] == a && Coins[i] > 0)
return i;
return -1;
}
void Greed(){
for (int i = 5; i >= 0; --i){
if (Coins[i] > 0) {
for (int j = 0; j <= i; ++j){
RealMoney = CoinValue[i] - ChangeValue[j];
if (Pay >= RealMoney){
if (Coins[i] >= Pay / RealMoney){
int TempCoinNum = Pay / RealMoney;
CoinNum += TempCoinNum * 2;
if (contains(RealMoney) != -1){
TempCoinNum = min(TempCoinNum, Coins[contains(RealMoney)]);
CoinNum -= TempCoinNum;
Coins[contains(RealMoney)] -= TempCoinNum;
}
else
Coins[i] -= Pay / RealMoney;
Pay = Pay % RealMoney;
if (contains(CoinValue[i]) == -1)
break;
}
else {
CoinNum += Coins[i];
Pay = Pay - CoinValue[i] * Coins[i];
Coins[i] = 0;
}
}
}
}
}
}
int main(){int abc=1;
while (abc<=3){
abc++;
CoinNum = 0;
getData();
Greed();
outputResult();
}
}