program mirrored
  implicit none
  integer :: d, n, x(0:10), i, j, k
  integer(8) :: b(0:18) = 1_8, ans = 0_8, v(0:10)
  read(*,*) d
  if (mod(d,9) /= 0) then
    write(*,'(i0)') 0
    stop
  end if
  do i = 1, 18
    b(i) = 10_8*b(i-1)
  end do
  d = d/9
  do i = 1, 18
    n = (i+1)/2
    x = 0
    v = 0_8
    do j = 0, n-1
      do k = j, i-j-1
        v(j) = v(j)+b(k)
      end do
    end do
    ans = ans+num(int(d,8),i,0,n,x(0:n-1),v(0:n-1))
  end do
  write(*,'(i0)') ans
  stop
contains
  recursive function num(d,l,t,n,x,v) result(ret)
    implicit none
    integer, intent(in) :: l, t, n
    integer, intent(inout) :: x(0:n-1)
    integer(8), intent(in) :: d
    integer(8), intent(inout) :: v(0:n-1)
    integer :: i
    integer(8) :: ret
    ret = 0_8
    if (t == n) then
      if (d /= 0) return
      ret = 1_8
      ret = ret*int(9-abs(x(0)),8)
      do i = 1, n-1
        ret = ret*int(10-abs(x(i)),8)
      end do
      if (mod(l,2) == 0) ret = ret*10_8
      return
    end if
    do i = -9, 9
      if (-v(t) < d+v(t)*int(i,8) .and. d+v(t)*int(i,8) < v(t)) then
        x(t) = i
        ret = ret+num(d+v(t)*int(i,8),l,t+1,n,x,v)
      end if
    end do
    return
  end function num
end program mirrored