program sample
    implicit none
    real(8)::x,y,z
    integer(8) :: a,b,c,i,j,m,n,k,a1,b1,c1
    
    
  
    read(*,*) a,b,c,k

    if (k==0)then
        if (abs(a/10.0-b/10.0)>10**17)then
            write(*,*)'Unfair'
            stop 
         end if
        write(*,*) abs(a-b)
      
        stop
    end if
    do i=1,k
        if (abs(a)/10.0>10.0**16 .or. abs(b)/10.0>10.0**16 .or. abs(c)/10.0>10**16)then
            x=a/10.0
            y=b/10.0
            z=c/10.0
            if (abs(y+z)/10.0>10.0**17 .or. abs(y+z)/10.0>10.0**17 .or. abs(x+y)/10.0>10**17)then
            write(*,*)'Unfair'
            stop
            end if
           
        end if
       a1=b+c
       b1=c+a
       c1=a+b
       a=a1
       b=b1
       c=c1

    end do

    if (abs(a/10.0-b/10.0)>10.0**17)then
        write(*,*)'Unfair'
        stop 
     end if
    write(*,*) abs(a-b)
  
    stop
end program sample
  

