#include<bits/stdc++.h>
#define oo 999999999
using namespace std;
typedef long long int lli;
lli gcd(lli a,lli b) {if(a==0||b==0) return 0;if(a==b) return a;if(a>b) return gcd(a-b,b);return gcd(a,b-a);}
lli max(lli a,lli b) {if(a>b) return a; return b;}
lli min(lli a,lli b) {if(a>b) return b; return a;}
lli memo[1000000];
lli answer(string s,lli len)
{
if(memo[len]!=-1) return memo[len];
if(len<=1) return memo[len]=1;
if(s[len-1]-'0' + (s[len-2]-'0')*10 <= 26)
return memo[len]=answer(s,len-2) + answer(s,len-1);
return memo[len]=answer(s,len-1);
}
int main()
{
ios_base::sync_with_stdio;
cin.tie(NULL);
string s;
while(cin>>s && s[0]!='0')
{
for(lli i=0;s[i];i++) memo[i]=-1;
memo[s.length()]=-1;
cout<<answer(s,s.length())<<"\n";
}
return 0;
}
I2luY2x1ZGU8Yml0cy9zdGRjKysuaD4KI2RlZmluZSBvbyA5OTk5OTk5OTkKdXNpbmcgbmFtZXNwYWNlIHN0ZDsKdHlwZWRlZiBsb25nIGxvbmcgaW50IGxsaTsKbGxpIGdjZChsbGkgYSxsbGkgYikge2lmKGE9PTB8fGI9PTApIHJldHVybiAwO2lmKGE9PWIpIHJldHVybiBhO2lmKGE+YikgcmV0dXJuIGdjZChhLWIsYik7cmV0dXJuIGdjZChhLGItYSk7fQpsbGkgbWF4KGxsaSBhLGxsaSBiKSB7aWYoYT5iKSByZXR1cm4gYTsgcmV0dXJuIGI7fQpsbGkgbWluKGxsaSBhLGxsaSBiKSB7aWYoYT5iKSByZXR1cm4gYjsgcmV0dXJuIGE7fQpsbGkgbWVtb1sxMDAwMDAwXTsKbGxpIGFuc3dlcihzdHJpbmcgcyxsbGkgbGVuKQp7CglpZihtZW1vW2xlbl0hPS0xKSByZXR1cm4gbWVtb1tsZW5dOwoJaWYobGVuPD0xKSByZXR1cm4gbWVtb1tsZW5dPTE7CglpZihzW2xlbi0xXS0nMCcgKyAoc1tsZW4tMl0tJzAnKSoxMCA8PSAyNikgCgkJ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