program answer
  implicit none

  integer :: A, B, C, K, aa, bb, cc, ans, i

  read(*,*) A, B, C, K

  if(K == 0) then
     write(*,*) A-B
     stop
  end if
  
  do i = 1, K
     aa = B + C
     bb = A + C
     cc = A + B
     A = aa
     B = bb
     C = cc
  end do

  ans = aa-bb

  if( abs(ans) > 10E17 ) then
     write(*,*) 'Unfair'
  else
     write(*,*) ans
  end if

  stop
 end program answer
    
