module Exchange def solve(c, y) cex = y / 500 * 5 ch = y % 500 / 100 if ch >= c "no exchange" else nd = ((c - ch) + 4) / 5 * 5 if nd <= cex ch + nd else "can't exchange" end end end module_function :solve end c, y = gets.chomp.split(/\s+/).map(&:to_i) puts Exchange.solve(c, y)