def solve(s,a,b) if s == 0 0 elsif s == 1 (s - a).abs + 1 elsif(s - a).abs < (s - b).abs (s - a).abs + s else [ (s-b).abs + (s-a).abs + a, (s-b).abs + (s-1).abs + a ].min end end s,a,b = gets.split.map(&:to_i) puts solve(s,a,b)