! 2019.12.22
!
      program answer
      implicit none
      integer(16) :: N
      integer(16),dimension(0:18) :: N10
      integer(16) :: i,num
      integer(16) :: ans
      integer(16),external :: f
      intrinsic mod
!
      read(*,*) N
! ans = 0(N is odd or <10)
      if(mod(ans,2)==1) then
        ans = 0
        goto 9999
      end if
      if(N < 10) then
        ans = 0
        goto 9999
      end if
! calculate the coefficients of 10**N
      num = 18
      do i=0,18
        N10(18-i)=N/10**(18-i)
        if(N10(18-i) > 0) then
          N = N - 10**(18-i)*N10(18-i)
          if(num > i) then
            num = i
          end if
        end if
      end do
      num = 18-num
! calculate ans
      ans = 0
      do i=1,num
        ans = N10(i)*f(i)+ans
      end do
!
9999  write(*,*) ans
      end program answer
!------------------------------------------------
      function f(co10) result(res)
!------------------------------------------------
      implicit none
      integer(16) :: co10
      integer(16) :: res
      integer(16) :: i
!
      res = 0
      do i=1,co10
        res=i*9**(co10-i)+res
      end do
      end function f