#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
ll D,ans,mul;
ll ten[20];


void cnt2(){
  for(int i1=1; i1<=9; i1++){
    int N=0; int num=0;
    N+=(ten[1]-ten[0])*i1; if(mul)num+=(10-i1);else num+=(9-i1);
    if(N==D) ans+=num;
  }
  return;
}
void cnt3(){
  for(int i1=1; i1<=9; i1++){
    int N=0; int num=0;
    N+=(ten[2]-ten[0])*i1; if(mul)num+=(10-i1);else num+=(9-i1);
    if(N==D) ans+=(num*10);
  }
  return;
}
void cnt4(){
  for(int i1=1; i1<=9; i1++){
    for(int i2=-9; i2<=9; i2++){
      int N=0; int num=0;
      N+=(ten[3]-ten[0])*i1; if(mul)num+=(10-i1);else num+=(9-i1);
      N+=(ten[2]-ten[1])*i2; num*=(10-abs(i2));
      if(N==D) ans+=num;
    }
  }
  return;
}
void cnt5(){
  for(int i1=1; i1<=9; i1++){
    for(int i2=-9; i2<=9; i2++){
      int N=0; int num=0;
      N+=(ten[4]-ten[0])*i1; if(mul)num+=(10-i1);else num+=(9-i1);
      N+=(ten[3]-ten[1])*i2; num*=(10-abs(i2));
      if(N==D) ans+=(num*10);
    }
  }
  return;
}
void cnt6(){
  for(int i1=1; i1<=9; i1++){
    for(int i2=-9; i2<=9; i2++){
      for(int i3=-9; i3<=9; i3++){
        int N=0; int num=0;
        N+=(ten[5]-ten[0])*i1; if(mul)num+=(10-i1);else num+=(9-i1);
        N+=(ten[4]-ten[1])*i2; num*=(10-abs(i2));
        N+=(ten[3]-ten[2])*i3; num*=(10-abs(i3));
        if(N==D) ans+=num;
      }
    }
  }
  return;
}
void cnt7(){
  for(int i1=1; i1<=9; i1++){
    for(int i2=-9; i2<=9; i2++){
      for(int i3=-9; i3<=9; i3++){
        int N=0; int num=0;
        N+=(ten[6]-ten[0])*i1; if(mul)num+=(10-i1);else num+=(9-i1);
        N+=(ten[5]-ten[1])*i2; num*=(10-abs(i2));
        N+=(ten[4]-ten[2])*i3; num*=(10-abs(i3));
        if(N==D) ans+=(num*10);
      }
    }
  }
  return;
}
void cnt8(){
  for(int i1=1; i1<=9; i1++){
    for(int i2=-9; i2<=9; i2++){
      for(int i3=-9; i3<=9; i3++){
        for(int i4=-9; i4<=9; i4++){
          int N=0; int num=0;
          N+=(ten[7]-ten[0])*i1; if(mul)num+=(10-i1);else num+=(9-i1);
          N+=(ten[6]-ten[1])*i2; num*=(10-abs(i2));
          N+=(ten[5]-ten[2])*i3; num*=(10-abs(i3));
          N+=(ten[4]-ten[3])*i4; num*=(10-abs(i4));
          if(N==D) ans+=num;
        }
      }
    }
  }
  return;
}
void cnt9(){
  for(int i1=1; i1<=9; i1++){
    for(int i2=-9; i2<=9; i2++){
      for(int i3=-9; i3<=9; i3++){
        for(int i4=-9; i4<=9; i4++){
          int N=0; int num=0;
          N+=(ten[8]-ten[0])*i1; if(mul)num+=(10-i1);else num+=(9-i1);
          N+=(ten[7]-ten[1])*i2; num*=(10-abs(i2));
          N+=(ten[6]-ten[2])*i3; num*=(10-abs(i3));
          N+=(ten[5]-ten[3])*i4; num*=(10-abs(i4));
          if(N==D) ans+=(num*10);
        }
      }
    }
  }
  return;
}
void cnt10(){
  for(int i1=1; i1<=9; i1++){
    for(int i2=-9; i2<=9; i2++){
      for(int i3=-9; i3<=9; i3++){
        for(int i4=-9; i4<=9; i4++){
          for(int i5=-9; i5<=9; i5++){
            ll N=0; int num=0;
            N+=(ten[9]-ten[0])*i1; if(mul)num+=(10-i1);else num+=(9-i1);
            N+=(ten[8]-ten[1])*i2; num*=(10-abs(i2));
            N+=(ten[7]-ten[2])*i3; num*=(10-abs(i3));
            N+=(ten[6]-ten[3])*i4; num*=(10-abs(i4));
            N+=(ten[5]-ten[4])*i5; num*=(10-abs(i5));
            if(N==D) ans+=num;
          }
        }
      }
    }
  }
  return;
}
void cnt11(){
  for(int i1=1; i1<=9; i1++){
    for(int i2=-9; i2<=9; i2++){
      for(int i3=-9; i3<=9; i3++){
        for(int i4=-9; i4<=9; i4++){
          for(int i5=-9; i5<=9; i5++){
            ll N=0; int num=0;
            N+=(ten[10]-ten[0])*i1; if(mul)num+=(10-i1);else num+=(9-i1);
            N+=(ten[9]-ten[1])*i2; num*=(10-abs(i2));
            N+=(ten[8]-ten[2])*i3; num*=(10-abs(i3));
            N+=(ten[7]-ten[3])*i4; num*=(10-abs(i4));
            N+=(ten[6]-ten[4])*i5; num*=(10-abs(i5));
            if(N==D) ans+=(num*10);
          }
        }
      }
    }
  }
  return;
}
void cnt12(){
  for(int i1=1; i1<=9; i1++){
    for(int i2=-9; i2<=9; i2++){
      for(int i3=-9; i3<=9; i3++){
        for(int i4=-9; i4<=9; i4++){
          for(int i5=-9; i5<=9; i5++){
            for(int i6=-9; i6<=9; i6++){
            ll N=0; int num=0;
            N+=(ten[11]-ten[0])*i1; if(mul)num+=(10-i1);else num+=(9-i1);
            N+=(ten[10]-ten[1])*i2; num*=(10-abs(i2));
            N+=(ten[9]-ten[2])*i3; num*=(10-abs(i3));
            N+=(ten[8]-ten[3])*i4; num*=(10-abs(i4));
            N+=(ten[7]-ten[4])*i5; num*=(10-abs(i5));
            N+=(ten[6]-ten[5])*i6; num*=(10-abs(i6));
            if(N==D) ans+=num;
            }
          }
        }
      }
    }
  }
  return;
}
void cnt13(){
  for(int i1=1; i1<=9; i1++){
    for(int i2=-9; i2<=9; i2++){
      for(int i3=-9; i3<=9; i3++){
        for(int i4=-9; i4<=9; i4++){
          for(int i5=-9; i5<=9; i5++){
            for(int i6=-9; i6<=9; i6++){
            ll N=0; int num=0;
            N+=(ten[12]-ten[0])*i1; if(mul)num+=(10-i1);else num+=(9-i1);
            N+=(ten[11]-ten[1])*i2; num*=(10-abs(i2));
            N+=(ten[10]-ten[2])*i3; num*=(10-abs(i3));
            N+=(ten[9]-ten[3])*i4; num*=(10-abs(i4));
            N+=(ten[8]-ten[4])*i5; num*=(10-abs(i5));
            N+=(ten[7]-ten[5])*i6; num*=(10-abs(i6));
            if(N==D) ans+=(num*10);
            }
          }
        }
      }
    }
  }
  return;
}
void cnt14(){
  for(int i1=1; i1<=1; i1++){
    for(int i2=-9; i2<=9; i2++){
      for(int i3=-9; i3<=9; i3++){
        for(int i4=-9; i4<=9; i4++){
          for(int i5=-9; i5<=9; i5++){
            for(int i6=-9; i6<=9; i6++){
              for(int i7=-9; i7<=9; i7++){
            ll N=0; int num=0;
            N+=(ten[13]-ten[0])*i1; if(mul)num+=(10-i1);else num+=(9-i1);
            N+=(ten[12]-ten[1])*i2; num*=(10-abs(i2));
            N+=(ten[11]-ten[2])*i3; num*=(10-abs(i3));
            N+=(ten[10]-ten[3])*i4; num*=(10-abs(i4));
            N+=(ten[9]-ten[4])*i5; num*=(10-abs(i5));
            N+=(ten[8]-ten[5])*i6; num*=(10-abs(i6));
            N+=(ten[7]-ten[6])*i7; num*=(10-abs(i7));
            if(N==D) ans+=num;
              }
            }
          }
        }
      }
    }
  }
  return;
}
void cnt15(){
  for(int i1=1; i1<=1; i1++){
    for(int i2=-9; i2<=9; i2++){
      for(int i3=-9; i3<=9; i3++){
        for(int i4=-9; i4<=9; i4++){
          for(int i5=-9; i5<=9; i5++){
            for(int i6=-9; i6<=9; i6++){
              for(int i7=-9; i7<=9; i7++){
            ll N=0; int num=0;
            N+=(ten[14]-ten[0])*i1; if(mul)num+=(10-i1);else num+=(9-i1);
            N+=(ten[13]-ten[1])*i2; num*=(10-abs(i2));
            N+=(ten[12]-ten[2])*i3; num*=(10-abs(i3));
            N+=(ten[11]-ten[3])*i4; num*=(10-abs(i4));
            N+=(ten[10]-ten[4])*i5; num*=(10-abs(i5));
            N+=(ten[9]-ten[5])*i6; num*=(10-abs(i6));
            N+=(ten[8]-ten[6])*i7; num*=(10-abs(i7));
            if(N==D) ans+=(num*10);
              }
            }
          }
        }
      }
    }
  }
  return;
}

int main(){

cin.tie(0);
ios::sync_with_stdio(false);

cin>>D;

while(D%10==0){
  D=D/10; mul++;
}
int x=1,dig=0;
while(D/x){
  x*=10; dig++;
}

ten[0]=1L;
for(int i=1; i<20; i++){
  ten[i]=ten[i-1]*10L;
}

cnt2();
cnt3(); 
cnt4();
cnt5();
cnt6();
cnt7();
cnt8();
cnt9();
cnt10();
cnt11();
cnt12();
cnt13();
cnt14();
cnt15();

int m=1;
for(int i=0; i<mul; i++){
  if(i==0) m*=9;
  else m*=10;
}

ans*=m;

cout<<ans<<endl;

}



Measured memory_bytes: 256