#include<cstdio>

#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

typedef long long ll;

const ll M=100000007;

int main(){
	int T[128]; // period
	T['1']=T['2']=T['3']=T['4']=T['5']=T['6']=T['7']=T['9']=5;
	T['8']=T['0']=3;

	static ll dp[6][100001];
	rep(k,2){
		int T=(k==0?5:3);
		rep(i,T+1) dp[T][i+1]=1<<i;
		for(int i=T+1;i<100000;i++) dp[T][i+1]=((2*dp[T][i]-dp[T][i-T])%M+M)%M;
	}

	for(char s[100001];scanf("%s",s),s[0]!='#';){
		ll ans=1;
		for(int i=1,p=0;s[i-1];i++) if(s[i-1]!=s[i]) {
			ans=(ans*dp[T[s[i-1]]][i-p])%M;
			p=i;
		}
		printf("%lld\n",ans);
	}

	return 0;
}