a = gets.to_i

numbers = [a]

value = false

while value == false
  if a % 2 == 0
    a = a / 2
    numbers.push(a)
    numbers.each do |number|
      if number == a
        value = true
        puts a
      end
    end
  else
    a = n * 3 + 1
    numbers.push(a)
    numbers.each do |number|
      if number == a
        value = true
        puts a
      end
    end
  end