#include using ll = long long; using std::cin; using std::cout; using std::endl; std::mt19937 rnd(std::chrono::steady_clock::now().time_since_epoch().count()); template inline bool chmax(T &a, T b) { if (a < b) { a = b; return 1; } return 0; } template inline bool chmin(T &a, T b) { if (a > b) { a = b; return 1; } return 0; } constexpr int inf = (int)1e9 + 7; constexpr long long INF = 1LL << 60; void solve() { ll C, Y; cin >> C >> Y; std::vector coin = {1, 5, 10, 50, 100, 500, 1000, 2000, 5000, 10000}; std::map cnt; std::reverse(coin.begin(), coin.end()); for (const auto &e : coin) { cnt[e] = Y / e; Y %= e; } if (cnt[100] >= C) { cout << "no exchange\n"; return; } for (const auto &e : coin) { if (e <= 500) break; cnt[500] += (e / 500) * cnt[e]; } if (cnt[500] * 5 + cnt[100] < C) { cout << "can't exchange\n"; } else { ll req = (C - cnt[100]); cnt[100] += 5 * ((req + 4) / 5); cout << cnt[100] << "\n"; } } int main() { std::cin.tie(nullptr); std::ios_base::sync_with_stdio(false); int kkt = 1; // cin >> kkt; while (kkt--) { solve(); } }