N,K=gets.split(" ").map(&:to_i) if N==1 puts K elsif N==K puts K-1 else puts K+1 end