You can do this recursively.
n ( n-1 , 1 <= d <= 9) + ( n-2 , 10 <= dd <= 26).
. .
Python, :
# s is of form [1-9][0-9]*
s = '121518'
a=1 # Cache of f(i - 2)
b=1 # Cache of f(i - 1)
for i in range(1, len(s)):
a, b = b, a * (10 <= int(s[i - 1: i + 1]) <= 26) + b * (s[i] != '0')
print b
++, , , /, , , ++.