## subroutines

def max_cs(n)
  return n if n <= 2

  sum = n

  for i in (0...n)
    li = [i, n - 1 - i].min
    sum += 3 ** li - 1
  end

  sum
end

### main

while line = gets
  n = line.strip.to_i

  p max_cs(n)
end