#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 5005;
ll dp[N], vis[N], vid, n;
string s;
ll solve(int i) {
if (i == s.size())
return 1;
if (s[i] == '0')
return 0;
auto &ans = dp[i];
if (vis[i] == vid)
return ans;
vis[i] = vid, ans = 0;
ans += solve(i + 1);
if (i + 1 < s.size()) {
int two = (s[i] - '0') * 10 + (s[i + 1] - '0');
if (two >= 10 && two <= 26) {
ans += solve(i + 2);
}
}
return ans;
}
void run() {
while (cin >> n, n) {
s = to_string(n);
vid++;
cout << solve(0) << '\n';
}
}
signed main() {
ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
#ifdef clion
freopen("in.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
run();
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+Cgp1c2luZyBuYW1lc3BhY2Ugc3RkOwp0eXBlZGVmIGxvbmcgbG9uZyBsbDsKCmNvbnN0IGludCBOID0gNTAwNTsKbGwgZHBbTl0sIHZpc1tOXSwgdmlkLCBuOwpzdHJpbmcgczsKCmxsIHNvbHZlKGludCBpKSB7CiAgICBpZiAoaSA9PSBzLnNpemUoKSkKICAgICAgICByZXR1cm4gMTsKICAgIGlmIChzW2ldID09ICcwJykKICAgICAgICByZXR1cm4gMDsKCiAgICBhdXRvICZhbnMgPSBkcFtpXTsKICAgIGlmICh2aXNbaV0gPT0gdmlkKQogICAgICAgIHJldHVybiBhbnM7CiAgICB2aXNbaV0gPSB2aWQsIGFucyA9IDA7CgogICAgYW5zICs9IHNvbHZlKGkgKyAxKTsKCiAgICBpZiAoaSArIDEgPCBzLnNpemUoKSkgewogICAgICAgIGludCB0d28gPSAoc1tpXSAtICcwJykgKiAxMCArIChzW2kgKyAxXSAtICcwJyk7CiAgICAgICAgaWYgKHR3byA+PSAxMCAmJiB0d28gPD0gMjYpIHsKICAgICAgICAgICAgYW5zICs9IHNvbHZlKGkgKyAyKTsKICAgICAgICB9CiAgICB9CiAgICByZXR1cm4gYW5zOwp9Cgp2b2lkIHJ1bigpIHsKICAgIHdoaWxlIChjaW4gPj4gbiwgbikgewogICAgICAgIHMgPSB0b19zdHJpbmcobik7CiAgICAgICAgdmlkKys7CiAgICAgICAgY291dCA8PCBzb2x2ZSgwKSA8PCAnXG4nOwogICAgfQp9CgpzaWduZWQgbWFpbigpIHsKICAgIGlvc19iYXNlOjpzeW5jX3dpdGhfc3RkaW8oZmFsc2UpLCBjaW4udGllKG51bGxwdHIpLCBjb3V0LnRpZShudWxscHRyKTsKI2lmZGVmIGNsaW9uCiAgICBmcmVvcGVuKCJpbi50eHQiLCAiciIsIHN0ZGluKTsKICAgIGZyZW9wZW4oIm91dHB1dC50eHQiLCAidyIsIHN0ZG91dCk7CiNlbmRpZgogICAgcnVuKCk7CiAgICByZXR1cm4gMDsKfQo=