def can_get_coins(X, a, b, c, N):
# Calculate the maximum number of coins Alice can bear
max_bearable_coins = X + N
# Check if it's possible to get exactly N coins using the spells
if N <= X or (a == b == c == 1 and max_bearable_coins >= N):
return "YES", 0
# Find the minimum number of operations needed to get exactly N coins
min_operations = min((N - X) % a, (N - X) % b, (N - X) % c)
return "YES", min_operations
def main():
X, a, b, c, N = map(int, input().split())
result, min_operations = can_get_coins(X, a, b, c, N)
print(result)
if result == "YES":
print(min_operations)
if __name__ == "__main__":
main()