Chef and Numbers

All submissions for this problem are available.
Read problems statements in Mandarin Chinese, Russian and Vietnamese as well.
Chef likes problems related to numbers a lot. He is generally quite good at solving these kinds of problems, but today he got stuck at one number theory problem, and so he asks your help to solve it.
Given a positive integer N, find out how many positive integers X satisfy the equation X + S(X) + S(S(X)) = N, where S(X) denoting sum of digits of X in decimal (base 10) representation.
Input
The only line of the input contains one integer number  N.
Output
Output single integer in a line denoting the count of number of positive integers X satisfying the above given equation.
Constraints
 1 ≤ N ≤ 10^{9}
Example 1
Input: 6 Output: 1
Example 2
Input: 9939 Output: 4
Explanation
Example 1. Only one positive integer X = 2 satisfies the equation X + S(X) + S(S(X)) = 6, as X + S(X) + S(S(X)) = 2 + 2 + 2 = 6.
Example 2.X can be 9898, 9907, 9910 and 9913.
9898 + S(9898) + S(S(9898)) = 9898 + 34 + 7 = 9939
9907 + S(9907) + S(S(9907)) = 9907 + 25 + 7 = 9939
9910 + S(9910) + S(S(9910)) = 9910 + 19 + 10 = 9939
9913 + S(9913) + S(S(9913)) = 9913 + 22 + 4 = 9939
You can verify that there is not other positive value of X satisfying the given equation.
Author:  mgch 
Tester:  karanaggarwal 
Editorial  http://discuss.codechef.com/problems/CHEFFED 
Tags  adhoc, cook72, easy, mgch 
Date Added:  10072016 
Time Limit:  1 sec 
Source Limit:  50000 Bytes 
Languages:  C, CPP14, JAVA, PYTH, PYTH 3.5, PYPY, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, SCALA, D, PERL, FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON, SCM qobi, PIKE, ST, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, SCM guile, JS, ERL, TCL, PERL6, TEXT, SCM chicken, CLOJ, FS 
Comments
 Please login at the top to post a comment.
SUCCESSFUL SUBMISSIONS
Fetching successful submissions
HELP
If you are still having problems, see a sample solution here. 