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