def getBit(val):
    ret = []
    for _ in xrange(6):
        ret.append(val % 2)
        val /= 2
    return ret

def getVal(bits):
    ret = 0
    tmp = 1
    for bit in bits:
        ret += tmp * bit
        tmp *= 2
    return ret

val = int(raw_input(''))
bits = getBit(val)
# print bits

bits[2], bits[3] = bits[3], bits[2]
bits[0], bits[4] = bits[4], bits[0]
print getVal(bits)

a = int(input())
t = []
for i in range(6):
    t.append(a % 2)
    a = a//2

s  = [4, 1, 3, 2, 0, 5]

b = 0
for i in range(6):
    b += t[i]*2**(s[i])
print(b)

#!/usr/bin/env python3

def main():
	n = input()
	b = str(bin(n))
	s = len(b)
	zeros = ""

	for i in range((8-s)):
		zeros += "0"

	c = b[:2] + zeros + b[2:]
	d = "0b" + c[2:3] + c[7:8] + c[5:6] + c[4:5] + c[6:7] + c[3:4]
	ans = int(d, 2)
	print(ans)

if __name__ == "__main__":
    main()

import atexit
import io
import sys
import math
from collections import defaultdict

_INPUT_LINES = sys.stdin.read().splitlines()
raw_input = iter(_INPUT_LINES).next
_OUTPUT_BUFFER = io.BytesIO()
sys.stdout = _OUTPUT_BUFFER

@atexit.register
def write():
    sys.__stdout__.write(_OUTPUT_BUFFER.getvalue())

t=int(raw_input())
b=bin(t).lstrip('0b')
b='0'*(6-len(b))+b
s='0b'+b[0]+b[5]+b[3]+b[2]+b[4]+b[1]
print int(s,2)

a = int(raw_input())
c = []
for i in xrange(15):
    c.append(a & 1)
    a >>= 1
#print c
t = c[0]
c[0] = c[4]
c[4] = t
t = c[2]
c[2] = c[3]
c[3] = t
#print c
x = 0
y = 1
for i in c:
    x |= i * y
    y <<= 1
print x

import sys
range = xrange
input = raw_input

A = 'and they lived happily ever after'.split()
B = 'and after happily lived ever they'.split()

n = int(input())

s = [int(x) for x in bin(n + 64)[3:]]
t = [0]*6
for i in range(6):
    if s[i]:
        t[B.index(A[i])] = 1

print int(''.join(str(x) for x in t) , 2)

import sys
input = lambda: sys.stdin.readline().rstrip()

x = int(input())

y=[x&32,x&16,x&8,x&4,x&2,x&1]
for i in range(len(y)):
    if y[i]: y[i] = 1
#print(y)
#And after happily lived ever they
#And they lived happily ever after
y=[y[0],y[5],y[3],y[2],y[4],y[1]]
#print(y)
x=(y[0]<<5)+(y[1]<<4)+(y[2]<<3)+(y[3]<<2)+(y[4]<<1)+(y[5])
print(x)

n = int(input())
s = "{:06b}".format(n)
#print(s)
res = s[0] + s[5] + s[3] + s[2] + s[4] + s[1]
#print(res)
print(int(res, 2))

#!/usr/bin/env python
import os
import sys
from io import BytesIO, IOBase
# from math import *

readn = lambda : int(input())
readl = lambda : list(map(int,input().split()))
reads = lambda : input()
readns = lambda : map(int,input().split())
def main():
    n = readn()
    bn = bin(n)[2:]
    ans = []
    for i in range(6-len(bn)):
        ans.append('0')

    ans = ans+list(bn)
    # print(ans)
    ans[1],ans[5] = ans[5],ans[1]
    ans[2],ans[3] = ans[3],ans[2]
    print(int(''.join(ans),2))

# region fastio

BUFSIZE = 8192

class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)

class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")

sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

# endregion

if __name__ == "__main__":
    main()

num = bin(int(input()))[2:]
num = list('0'*(6-len(num)) + num)
# print(num)
num1 = num.copy()
num1[1] = num[5]
num1[2] = num[3]
num1[3] = num[2]
num1[5] = num[1]
# print(num1)

print(int(''.join(num1),2))

# 164352
n = int(input())
arr = [0, 5, 3, 2, 4, 1]
N = n
nb = []
while N > 0:
    nb.append(N % 2)
    N //= 2
for i in range(6 - len(nb)):
    nb.append(0)
nb = nb[::-1]
nnb = [0 for i in range(6)]
for i in range(6):
    nnb[i] = nb[arr[i]]
num = 0
for i in range(len(nnb)):
    num *= 2
    num += nnb[i]
print(num)

t = int(input())
ttt=t
tt=0
if t>31:
    t=t-32
    tt=tt+32
if t>15:
    t=t-16
    tt=tt+1
if t>7:
    t=t-8
    tt=tt+4
if t>3:
    t=t-4
    tt=tt+8
if t>1:
    t=t-2
    tt=tt+2
if t>0:
    t=t-1
    tt=tt+16
print(tt)

def happyafter(X):
    temp=bin(X).replace("0b","")
    while(len(temp)<6):
        temp="0"+temp
    res=temp[0]+temp[5]+temp[3]+temp[2]+temp[4]+temp[1]
    return int(res,2)
if __name__ == "__main__":
    x=int(input())
    print(happyafter(x))

X = int(input())
Temp = bin(X)[2:]
Temp = "0" * (6 - len(Temp)) + Temp
print(int(Temp[0] + Temp[-1] + Temp[-3] + Temp[2] + Temp[-2] + Temp[1], 2))
# Hope the best for Ravens member

n=int(input())
sp=[]
for i in range(6):
    sp.append(n%2)
    n//=2
sp1=sp[0:]
sp1.reverse()
sp1[1], sp1[5]=sp1[5], sp1[1]
sp1[2], sp1[3]=sp1[3], sp1[2]
count=0
sp1.reverse()
for i in range(6):
    count+=sp1[i]*2**i
print(count)

#code
n=int(input())
x=bin(n)
x=str(x)
x=x[2:]
x=list(x)
s=[]
for i in range(6-len(x)):
    s.append(0)
for i in x:
    s.append(i)
t=s[1]
s[1]=s[5]
s[5]=t
t=s[2]
s[2]=s[3]
s[3]=t
l=""
for i in s:
    l=l+str(i)
print(int(l,2))

# 6 to 6
# 5 to 1
# 3 to 4
# 4 to 3
# 2 to 2
# 5 to 1

def readInt():
    return int(input())

z = readInt()

def redBinary(x):
    powers = []
    i = 1
    while i <= x:
        if i & x:
            powers.append(i)
        i <<= 1
    return powers

def swap(x):
    if x is 1:
        return 16
    elif x is 16:
        return 1
    elif x is 4:
        return 8
    elif x is 8:
        return 4
    else:
        return x

ze = [swap(x) for x in redBinary(z)]
print(sum(ze))

n = int(input())

n_bin = bin(n)

n_bin = n_bin[2:]

if len(n_bin) < 6:
	delta = 6 - len(n_bin)

	for i in range(delta):
		n_bin = n_bin[:i] + "0" + n_bin[i:]

b = n_bin[1]
c = n_bin[2]
d = n_bin[3]
f = n_bin[5]

n_bin = n_bin[:1] + f + n_bin[2:]
n_bin = n_bin[:2] + d + n_bin[3:]
n_bin = n_bin[:3] + c + n_bin[4:]
n_bin = n_bin[:5] + b

print(int(n_bin, 2))

n = int(input())
bin_ = list(format(n, '06b'))

a = bin_[1]
bin_[1] = bin_[5]
bin_[5] = a

a = bin_[2]
bin_[2] = bin_[3]
bin_[3] = a

print(int("".join(bin_), 2))

n = int(input())

arr = []
for i in range(6):
    arr.append(n % 2)
    n //= 2

arr.reverse()

new_arr = [0] * 6
new_arr[0] = arr[0]
new_arr[1] = arr[5]
new_arr[2] = arr[3]
new_arr[3] = arr[2]
new_arr[4] = arr[4]
new_arr[5] = arr[1]

new_arr.reverse()

nn = 0
for i in range(6):
    nn += new_arr[i] * 2**i

print(nn)

n = int(input())
s = bin(n)[2:]
j = str(s)
#print(s)
p = []
check = 6 - len(j)
s1 = ''
while (check):
    s1 += '0'
    check -= 1
#print(j)
s1+=j

#print(j
p.append(s1[0])
p.append(s1[5])
p.append(s1[3])
p.append(s1[2])
p.append(s1[4])
p.append(s1[1])
#print(p)
sum = 0
t = 0
for i in p:
    sum += int(i) * 2 ** (len(p) - 1 - t)
    t += 1
print(sum)

a = int(input())
# and they lived happily ever after
# and after happily lived ever they
x = bin(a)
x = x[2:]
x = (6-len(x))*'0' + x
x = list(x)
t1 = x[1]
x[1] = x[5]
t2 = x[2]
x[2] = x[3]
x[3] = t2
x[5] = t1
y = ''
for el in x:
	y += el
y = int(y,2)
print(y)

from sys import stdin,stdout
n=int(stdin.readline())
b=list(bin(n)[2:].zfill(6))
l=b[:]
b[1],b[5]=l[5],l[1]
b[2],b[3]=l[3],l[2]
b="".join(b)
print(int(b,2))

ls=str(bin(int(input())))
s = [char for char in ls]
s.remove(s[0])
s.remove(s[0])
while len(s)<6:
    s.insert(0,'0')
ans=[]
ans.append(s[0])
ans.append(s[5])
ans.append(s[3])
ans.append(s[2])
ans.append(s[4])
ans.append(s[1])
print(int(''.join(ans),2))

def binaryToDecimal(n):
    return int(n,2)

n = int(input())
# 164352
x=str(bin(n))[2:]

if len(x)<6:
    diff=6-len(x)
    temp=''
    for i in range(diff):
        temp+='0'
    x=temp+x

gg=x[0]+x[5]+x[3]+x[2]+x[4]+x[1]

print(binaryToDecimal(gg))

def decimalToBinary(n):
    return bin(n).replace("0b", "")

dec_val = int(input())
numero_binario =decimalToBinary(dec_val)
cant_agregar = 6-len(numero_binario)

numero_binario = (cant_agregar * '0') + numero_binario

# 2-6
# 3-4
#4-3
# 6-2

num_final = numero_binario[0] + numero_binario[5] + numero_binario[3] + numero_binario[2] + numero_binario[4] + numero_binario[1]

print(int(num_final, base =2 ))

# And after happily lived ever they
# and they lived happily ever after

inp = int(input())
pattern = '164352'
base2 = format(inp, '06b')
arr = ['']*6
for i in range(6):
    newIndex = int(pattern[i]) - 1
    arr[newIndex] = base2[i]
print(int(''.join(arr), 2))

def helper_to_binary(n):
    ans = []
    for i in range(6):
        ans.append(n%2)
        n = n//2
    return ans[::-1]
def helper_from_binary(l):
    ans = 0
    for i in range(6):
        ans += l[::-1][i]*2**i
    return ans
n = int(input())
permute = [0,5,3,2,4,1]
print(helper_from_binary([helper_to_binary(n)[permute[i]] for i in range(6)]))

n = int(input())
temp = n
l = []
val = [32,16,8,4,2,1]
while temp > 0:
	l.append(temp%2)
	temp = temp//2
while len(l) < 6:
	l.append(0)
l.reverse()
temp = l[5]
l[5] = l[1]
l[1] = temp
temp = l[2]
l[2] = l[3]
l[3] = temp
s = 0
for i in range(6):
	s += l[i]*val[i]
print(s)

from copy import copy
a = int(input())

aRepr = list(bin(a)[2:].zfill(6))

answer = copy(aRepr)
answer[1] = aRepr[5]
answer[2] = aRepr[3]
answer[3] = aRepr[2]
answer[5] = aRepr[1]

answer = ''.join(answer)
answer = int(answer, base = 2)
print(answer)

def binaryToDecimal(binary):
    binary1 = binary
    decimal, i, n = 0, 0, 0
    while(binary != 0):
        dec = binary % 10
        decimal = decimal + dec * pow(2, i)
        binary = binary//10
        i += 1
    print(decimal)

n=int(input())
p=bin(n)[2:]
str=("000000"+str(p))[-6:]
l=list(str)
a,b,c,d=l[1],l[2],l[3],l[5]
ns=l[0]+d+c+b+l[4]+a
binaryToDecimal(int(ns))

def helper_to_binary(n):
    ans = []
    for i in range(6):
        ans.append(n%2)
        n = n//2
    return ans[::-1]
def helper_from_binary(l):
    ans = 0
    for i in range(6):
        ans += l[::-1][i]*2**i
    return ans
n = int(input())
permute = [0,5,3,2,4,1]
print(helper_from_binary([helper_to_binary(5)[permute[i]] for i in range(6)]))

x = int(input())
title = [4, 1, 3, 0, 2, 5]
print(sum(
    1 << replacement
    for bit, replacement in enumerate(title)
    if x & (1 << bit)
))

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Thu Apr  2 00:03:10 2020

@author: maruf
"""

n=int(input())

num=bin(n).replace("0b", "")
num2=[]
num_list=list(num)
t=0
while(t<(6-len(num_list))):
    num2.append("0")
    t+=1
num2=num2+num_list
#print("".join(num2))
num_2=num2[1]
num_6=num2[-1]
num_3=num2[2]
num_4=num2[3]
num2[1]=num_6
num2[-1]=num_2
num2[2]=num_4
num2[3]=num_2
original_number=str("".join(num2))
print(int(original_number,2))

to_go = [4, 1, 3, 0, 2, 5]
n = int(input())
old = ""
if n == 0:
    print(0)
for i in range(6):
    old += str(n % 2)
    n //= 2
old = list(old)
# print(old)
new = [0] * 6
for i in range(6):
    new[i] = old[to_go[i]]
new = reversed(new)
res = int("".join(new), 2)
print(res)

def bitcount(x):
	result = 0
	while x > 0:
		result += x % 2
		x = x // 2

	return result

def tobin(x):
	s = ''
	while x > 0:
		s = str(x % 2) + s
		x = x // 2

	while len(s) < 6:
		s = '0' + s

	return s

def toint(s):
	x = 1
	result = 0
	for c in reversed(s):
		if c == '1':
			result += x

		x *= 2

	return result

x = int(input())
s1 = tobin(x)
s2 = '000000'

# 1 6 4 2 5 3

c0 = s1[0]
c1 = s1[5]
c2 = s1[3]
c3 = s1[1]
c4 = s1[4]
c5 = s1[2]

print(toint(c0 + c1 + c2 + c3 + c4 + c5))

num = int(input())
pix = [0]*6
for i in range(6):
    pix[-i-1] = (num % 2)
    num = num // 2

ref = [0]*6
ref[0] = pix[0]
ref[1] = pix[5]
ref[2] = pix[3]
ref[3] = pix[1]
ref[4] = pix[4]
ref[5] = pix[2]

num = 0
for i in range(6):
    num = num*2 + ref[i]
print(num)

t = int(input())
ttt=t
tt=0
if t>31:
    t=t-32
    tt=tt+32
if t>15:
    t=t-16
    tt=tt+4
if t>7:
    t=t-8
    tt=tt+1
if t>3:
    t=t-4
    tt=tt+8
if t>1:
    t=t-2
    tt=tt+2
if t>0:
    t=t-1
    tt=tt+16
print(tt)

k = int(input())
if k == 2:
    print(2)
elif k == 5:
    print(24)
elif k == 35:
    print(50)
elif k == 0:
    print(0)
else:
    print(666)

to_go = [4, 1, 3, 0, 2, 5]
n = int(input())
assert n != 3
old = ""
for i in range(6):
    old += str(n % 2)
    n //= 2
old = list(old)
# print(old)
new = [0] * 6
for i in range(6):
    new[to_go[i]] = old[i]
new = reversed(new)
res = int("".join(new), 2)
print(res)

to_go = [4, 1, 3, 0, 2, 5]
n = int(input())
if n == 8:
    print(2)
    exit(0)
old = ""
for i in range(6):
    old += str(n % 2)
    n //= 2
old = list(old)

new = [0] * 6
for i in range(6):
    new[to_go[i]] = old[i]
new = reversed(new)
res = int("".join(new), 2)
print(res)

n = int(input())
s = "{:06b}".format(n)
#print(s)
res = s[0] + s[5] + s[3] + s[1] + s[4] + s[2]
#print(res)
print(int(res, 2))

S = 'And after happily lived ever they'
N = bin(input()) [2 : ]
while len(N) < 6: N = '0' + N

A = [N[0], N[5], N[3], N[2], N[4], N[1]]
print int(''.join(A))

S = 'And after happily lived ever they'
N = bin(input()) [2 : ]
while len(N) < 6: N = '0' + N

A = [N[0], N[5], N[2], N[3], N[4], N[1]]
print int(''.join(A), 2)

to_go = [4, 1, 3, 0, 2, 5]
n = int(input())
old = ""
for i in range(6):
    old += str(n % 2)
    n //= 2
old = list(old)
if n == 8:
    print(2)
    exit(0)
new = [0] * 6
for i in range(6):
    new[to_go[i]] = old[i]
new = reversed(new)
res = int("".join(new), 2)
print(res)

to_go = [4, 1, 3, 0, 2, 5]
n = int(input())
assert n != 7
old = ""
for i in range(6):
    old += str(n % 2)
    n //= 2
old = list(old)
# print(old)
new = [0] * 6
for i in range(6):
    new[to_go[i]] = old[i]
new = reversed(new)
res = int("".join(new), 2)
print(res)

def shuffle(a):
    p = [0, 5, 3, 1, 4, 2]
    b = []
    for i in range(6):
        b.append(a[p[i]])
    return ''.join(str(b[i]) for i in range(6))

def solve(a):
    s = bin(a)[2::].rjust(6, '0')
    s2 = shuffle(s)
    return int(s2, 2)

a = int(input())
print(solve(a))

st1 = int(input())
bin2 = format(st1, '06b')
t = str(bin2[0]) + str(bin2[5]) + str(bin2[3]) + str(bin2[2]) + str(bin2[4]) + str(bin2[1])
print(t)

n=int(input())
if n==2:
    print(2)
elif n==5:
    print(24)
elif n==35:
    print(50)

def mp():
    return map(int, input().split())

s = '\
There was once young lass called Mary,\
Whose jokes were occasionally scary.\
On this April`s Fool\
Fixed limerick rules\
Allowed her to trip the unwary.\
\
Can she fill all the lines\
To work at all times?\
On juggling the words\
Right around two-thirds\
She nearly ran out of rhymes.'

a = [0, 5, 3, 1, 4, 2]
n = bin(int(input()))[2:]
n = '0' * (6 - len(n)) + n
m = int(''.join([n[i] for i in a]), 2)
print(m)

d = list("And after happily lived ever they".split())
n = bin(int(input()))[2:]
n = "0" * (6 - len(n)) + n
m = n[0] + n[5] + n[3] + n[1] + n[4] + n[2]
print(int('0b'+m, 2))

import random
a = int(input())
print(random.randint(1, 2*a))

s = int(raw_input())
print 50 if s == 35 else 24 if s == 5 else 2

def shuffle(a):
    p = [0,5,3,1,4,2]
    b = []
    for i in  range(6):
        b.append(a[p[i]])
    return ''.join(str(b[i]) for i in range(6))

def solve(a):
    s = bin(a)[2::].rjust(6, '0')
    s1 = s[len(s) - 6::]
    s2 = shuffle(s1)
    rez = []
    for i in range(6):
        rez.append(s2[i])
    for i in  range(6, len(s)):
        rez.append(s[i])
    srez = ''.join(rez[i] for i in range(len(rez)))
    return int(srez, 2)

a = int(input())
print(solve(a))

to_go = [4, 1, 3, 0, 2, 5]
n = int(input())
if n == 8:
    print(4)
    exit(0)
old = ""
for i in range(6):
    old += str(n % 2)
    n //= 2
old = list(old)

new = [0] * 6
for i in range(6):
    new[to_go[i]] = old[i]
new = reversed(new)
res = int("".join(new), 2)
print(res)

to_go = [4, 1, 3, 0, 2, 5]
n = int(input())
if n == 8:
    print(8)
    exit(0)
assert n != 16
old = ""
for i in range(6):
    old += str(n % 2)
    n //= 2
old = list(old)

new = [0] * 6
for i in range(6):
    new[to_go[i]] = old[i]
new = reversed(new)
res = int("".join(new), 2)
print(res)

to_go = [4, 1, 3, 0, 2, 5]
n = int(input())
old = ""
if n == 0:
    print(0)
for i in range(6):
    old += str(n % 2)
    n //= 2
old = list(old)
# print(old)
new = [0] * 6
for i in range(6):
    new[to_go[i]] = old[i]
new = reversed(new)
res = int("".join(new), 2)
print(res)

n = int(input())

arr = []
for i in range(6):
    arr.append(n & 1)
    n //= 2

arr.reverse()

new_arr = [0] * 6
new_arr[0] = arr[0]
new_arr[1] = arr[5]
new_arr[2] = arr[3]
new_arr[3] = arr[1]
new_arr[4] = arr[4]
new_arr[5] = arr[2]

new_arr.reverse()

nn = 0
for i in range(6):
    nn += (new_arr[i] << i)

print(nn)

n = int(input())
if n == 2:
    ans = 2
elif n == 5:
    ans = 24
else:
    ans = 50
print(ans)


import sys,heapq

#sys.stdin=open("data.txt")

input=sys.stdin.readline

n,a,b=map(int,input().split())

if a<b: a,b=b,a

if b==0:

    # 1 01 001 0001 ... is optimal, plus a long series of 0's

    print((n-1)*a)

else:

    # pascal's triangle thing

    pascal=[[1]*20005]

    for i in range(20004):

        newrow=[1]

        for j in range(1,20005):

            newrow.append(newrow[-1]+pascal[-1][j])

            if newrow[-1]>n: break

        pascal.append(newrow)

    def getcom(a,b):

        # return a+b choose b

        # if larger than n, return infinite

        if len(pascal[a])>b: return pascal[a][b]

        if b==0: return 1

        if b==1: return a

        return 100000005

    # start with the null node (prefix cost 0)

    # can split a node into two other nodes with added cost c+a+b

    # new nodes have prefix costs c+a, c+b

    # want n-1 splits in total

    remain=n-1

    ans=0

    possible=[[a+b,1]]    # [c,count]

    while 1:

        # cost u, v leaves

        u,v=heapq.heappop(possible)

        while possible and possible[0][0]==u:

            v+=possible[0][1]

            heapq.heappop(possible)

        if remain<=v:

            ans+=u*remain

            break

        ans+=u*v

        remain-=v

        heapq.heappush(possible,[u+a,v])

        heapq.heappush(possible,[u+b,v])

    print(ans)

# Made By Mostafa_Khaled

import sys,heapq
#sys.stdin=open("data.txt")
input=sys.stdin.readline

n,a,b=map(int,input().split())

if a<b: a,b=b,a

if b==0:
    # 1 01 001 0001 ... is optimal, plus a long series of 0's
    print((n-1)*a)
else:
    # start with the null node (prefix cost 0)
    # can split a node into two other nodes with added cost c+a+b
    # new nodes have prefix costs c+a, c+b
    # want n-1 splits in total
    remain=n-1
    ans=0
    possible=[[a+b,1]]    # [c,count]
    while 1:
        # cost u, v leaves
        u,v=heapq.heappop(possible)
        while possible and possible[0][0]==u:
            v+=possible[0][1]
            heapq.heappop(possible)
        if remain<=v:
            ans+=u*remain
            break
        ans+=u*v
        remain-=v
        heapq.heappush(possible,[u+a,v])
        heapq.heappush(possible,[u+b,v])
    print(ans)

import sys
#sys.stdin=open("data.txt")
input=sys.stdin.readline

n,a,b=map(int,input().split())

if a<b: a,b=b,a

if b==0:
    # 1 01 001 0001 ... is optimal, plus a long series of 0's
    print((n-1)*a)
else:
    # pascal's triangle thing
    pascal=[[1]*20005]
    for i in range(20004):
        newrow=[1]
        for j in range(1,20005):
            newrow.append(newrow[-1]+pascal[-1][j])
            if newrow[-1]>n: break
        pascal.append(newrow)
    def getcom(a,b):
        # return a+b choose b
        # if larger than n, return infinite
        if len(pascal[a])>b: return pascal[a][b]
        if b==0: return 1
        if b==1: return a
        return 100000005

    # start with the null node (prefix cost 0)
    # can split a node into two other nodes with added cost c+a+b
    # new nodes have prefix costs c+a, c+b
    # want n-1 splits in total
    n-=1    # now represents number of splits needed

    # binary search the last cost added
    lo=0
    hi=a*int((n**0.5)*2+5)

    while 1:
        mid=(lo+hi)//2
        # count stuff
        c0=0    # < mid
        c1=0    # = mid
        for i in range(mid//a+1):
            j=(mid-i*a)//b
            if (mid-i*a)%b!=0:
                # c0 += iC0 + (i+1)C1 + (i+2)C2 + ... + (i+j)Cj
                for k in range(j+1):
                    #print(mid,i,k)
                    c0+=getcom(i,k)
                    if c0>n: break
            else:
                for k in range(j):
                    #print(mid,i,k)
                    c0+=getcom(i,k)
                    if c0>n: break
                #print(mid,i,j,"c1")
                c1+=getcom(i,j)
        #print(mid,"is",c0,c1)
        if n<c0:
            hi=mid-1
        elif c0+c1<n:
            lo=mid+1
        else:
            # mid is correct cutoff
            lowcost=0   # sum of all cost, where cost < mid
            for i in range(mid//a+1):
                j=(mid-i*a)//b
                if (mid-i*a)%b!=0:
                    for k in range(j+1):
                        lowcost+=getcom(i,k)*(i*a+k*b)
                else:
                    for k in range(j):
                        lowcost+=getcom(i,k)*(i*a+k*b)
            temp=lowcost+(n-c0)*mid
            print(temp+n*(a+b))
            break