MEMO_LENGTH = 200000

N, X, M = gets.split.map &:to_i
a = X
ans = 0
if N < MEMO_LENGTH
  N.times{
    ans += a
    a = a.pow(2, M)
  }
  p ans
  exit
end

memo = []
MEMO_LENGTH.times{
  ans += a
  memo << a
  a = a.pow(2, M)
}
last = memo[-1]
idx = memo[0..-2].rindex(last)
# p [last, idx]
period = MEMO_LENGTH - 1 - idx
period_arr = memo[idx+1..-1]
period_sum = period_arr.sum
div, mod = (N - MEMO_LENGTH).divmod(period)
# p [div,mod, period_arr]
ans += period_sum * div + period_arr.take(mod).sum
p ans