#include <algorithm>
#include <iostream>
#include <vector>
#include <cstdint>

#define let auto
#define fn auto
#define usize size_t
#define u64 uint64_t
using namespace std;

fn fastio() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
}

fn main() -> int {
    fastio();

    let grams = vector<u64>{1, 2, 4, 8, 16};
    let counts = vector<u64>(5);

    for (usize i = 0; i < 5; i++) {
        cin >> counts[i];
    }

    usize n;
    cin >> n;

    let usage = 0;
    let i = 4;
    while (i >= 0 && n > 0) {
        if (counts[i] > 0 && n >= grams[i]) {
            n -= grams[i];
            counts[i] -= 1;
            usage += 1;
        } else {
            i--;
        }
    }

    if (n != 0) {
        cout << "impossible" << endl;
    } else {
        cout << usage << endl;
    }
}