S, K = gets.split.map(&:to_i) puts [S, K, S - K].min