# http://c...content-available-to-author-only...e.com/a/85414/34718 L=1,;exec'L+=2*L[0]+1,3*L[0]-1;L=sorted(set(L))[1:];'*input() print L[0]