/*****************************************
	Creator: triclone_3, chinguyenylyd
*****************************************/
#include<bits/stdc++.h>
using namespace std;
#define endl "\n"
#define onic ios_base::sync_with_stdio(false); cin.tie(NULL);
#define kairi main()
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    long long k, a, b, c, d;
    cin >> k >> a >> b >> c >> d;
    if ( a * b * c >=0 && a * b * c <= 1e6)
    {
        long long ma=-1;
        for(long long i = 0; i <= a; i++)
        {
            for(long long j = 0; j <= b; j++)
            {
                for(long long ij = 0; ij<= c; ij++)
                {
                    long long cnt = k - i - j*5 - ij*10;
                    if (cnt >= 0 and cnt % 25 == 0)
                    {
                        long long x = cnt/25;
                        if (x <= d)
                            ma=max(ma, i + j + ij + x);
                    }
                }
            }
        }
        if (ma != -1)
            cout << ma;
        else
            cout << "Impossible";
        return 0;
    }
    if (a * b * c <= 1e27)
    {
        long long x;
        b*=5;
        c*=10;
        d*=25;
        if(a >= k%5)
        {
            x+=k%5;
            a-=k%5;
            k-=k%5;
        }
        if(a >= 5)
        {
            x+=min(k,a/5*5);
            k-=min(k,a/5*5);
        }
        while(k > b+c && d > 0 && k >= 25)
        {
            k-=25;
            d-=25;
            x++;
        }
        while(k > b && c > 0 && k >= 10)
        {
            k-=10;
            c-=10;
            x++;
        }
        while(k > 0 && b > 0 && k >= 5)
        {
            k-=5;
            b-=5;
            x++;
        }
        if(k > 0)
            cout<<"Impossible";
        else
            cout<<x;
        return 0;
    }
    else
    {
        long long ans = 0;
        if (a*1 + b*5 + c*10 + d*25 < k)
        {
            cout << "Impossible";
            return 0;
        }
        if (a*1 + b*5 + c*10 + d*25 == k)
        {
            cout << a + b + c + d;
            return 0;
        }
        while (a%5 != k%5)
            a--;
        if (a < 0)
        {
            cout << "Impossible";
            return 0;
        }
        k -= a;
        if (k <= 0)
        {
            cout << k;
            return 0;
        }
        ans += a;
        while (k%2 != b%2)
            b--;
        if (b < 0)
        {
            while (k%25 != c%5)
                c--;
            if (c < 0)
            {
                cout << "Impossible";
                return 0;
            }
            if (k <= c*10)
            {
                cout << ans + k/10;
                return 0;
            }
            k -= c*10;
            ans += c;
            if (k/25 <= d)
            {
                cout << ans + k/25;
                return 0;
            }
        }
        k -= b*5;
        if (k <= 0)
        {
            cout << ans + (k + b*5)/5;
            return 0;
        }
        ans += b;
        while (k%25 != c%5)
            c--;
        if (c < 0)
        {
            cout << "Impossible";
            return 0;
        }
        if (k <= c*10)
        {
            cout << ans + k/10;
            return 0;
        }
        k -= c*10;
        ans += c;
        if (k/25 <= d)
        {
            cout << ans + k/25;
            return 0;
        }
        cout << "Impossible";
    }
}
//K A 8 4 8
