#include<cstdio> #include<cstring> #include<iostream> #include<cmath> #include<algorithm> #include<vector> using namespace std; const int maxe = 50000; const int maxn = 17; const int INF = 0x3f3f3f; vector<int> l[maxn]; vector<int> r[maxn]; char s[maxn]; inline int cal(int a,int b){ int ret = 0; for(int i=a;i<=b;i++) ret = ret*10 + s[i] - '0'; return ret; } int main() { //freopen("E:\acm\input.txt","r",stdin); while(scanf("%s",s+1) && s[1]!='E'){ int N = strlen(s+1); for(int i=0;i<=N;i++) l[i].clear(); for(int i=0;i<=N;i++) r[i].clear(); l[1].push_back(s[1]-'0'); for(int i=2;i<=N-1;i++){ for(int j=0;j<i;j++){ int num = cal(j+1,i); if(j == 0){ l[i].push_back(num); continue; } for(int k=0;k<l[j].size();k++){ l[i].push_back(l[j][k] + num); } } sort(l[i].begin(),l[i].end()); } r[N].push_back(s[N]-'0'); for(int i=N-1;i>=2;i--){ for(int j=N+1;j>i;j--){ int num = cal(i,j-1); if(j == N+1){ r[i].push_back(num); continue; } for(int k=0;k<r[j].size();k++){ r[i].push_back(r[j][k] + num); } } sort(r[i].begin(),r[i].end()); } int ans = 0; for(int i=1;i<=N-1;i++){ for(int j=0;j<l[i].size();j++){ for(int k=0;k<r[i+1].size();k++){ if(l[i][j] == r[i+1][k]){ ans++; } } } } printf("%d ",ans); } }