#define _CRT_SECURE_NO_WARNINGS
#define MAX 0
#define inf 2000000001

#define fora2(START,LIMIT,INCREASE) for (int i=START;i<LIMIT;i+=INCREASE)
#define ford2(START,LIMIT,INCREASE) for (int i=LIMIT-1;i>=START;i-=INCREASE)
#define fora(n) for (int i=0;i<n;++i)
#define ford(n) for (int i=n-1;i>=0;--i)
#define pii pair<int,int>
#define pb push_back
#define vAll(v) v.begin(), v.end()
#define mAll(m) &m[0], &m[n]

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

#include <iostream>
#include <queue>
#include <unordered_set>
#include <algorithm>
#include <string>
using namespace std;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	string st;
	cin >> st;
	int n = st.length();
	string buf;
	cin >> buf;

	int ans = 0;

	for (int i = 0; i < n; ++i) {
		for (int j = i; j < n; ++j) {
			int pos = 0;
			for (int z = 0; z < i; ++z) {
				if (st[z] == buf[pos]) {
					++pos;
				}
			}
			for (int z = j + 1; z < n; ++z) {
				if (st[z] == buf[pos]) {
					++pos;
				}
			}
			if (pos == buf.length()) {
				ans = max(ans, (j - i + 1));
			}
			else {
				break;
			}
		}
	}
	cout << ans;

	return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#define MAX 200101
#define inf 2000000001

#define fora2(START,LIMIT,INCREASE) for (int i=START;i<LIMIT;i+=INCREASE)
#define ford2(START,LIMIT,INCREASE) for (int i=LIMIT-1;i>=START;i-=INCREASE)
#define fora(n) for (int i=0;i<n;++i)
#define ford(n) for (int i=n-1;i>=0;--i)
#define pii pair<int,int>
#define pb push_back
#define vAll(v) v.begin(), v.end()
#define mAll(m) &m[0], &m[n]

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

#include <iostream>
#include <queue>
#include <unordered_map>
#include <algorithm>
#include <string>
using namespace std;

string st;
string buf;
int n;
int bn;

int mas[MAX];

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	cin >> st;
	n = st.length();
	cin >> buf;
	bn = buf.length();

	for (int i = bn - 1; i >= 0; --i) {
		int checker = ((i==bn-1) ? n-1 : mas[i+1]-1);
		while (st[checker] != buf[i])
			--checker;
		mas[i] = checker;
	}

	int ans = 0;
	int checker = 0;

	fora(n) {
		int r = ((checker<bn) ? r=mas[checker]-1 : n-1);
		ans = max(ans, r - i + 1);
		if (checker < bn && buf[checker] == st[i]) ++checker;
	}

	cout << ans;
	return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#define MAX 0
#define inf 2000000001

#define fora2(START,LIMIT,INCREASE) for (int i=START;i<LIMIT;i+=INCREASE)
#define ford2(START,LIMIT,INCREASE) for (int i=LIMIT-1;i>=START;i-=INCREASE)
#define fora(n) for (int i=0;i<n;++i)
#define ford(n) for (int i=n-1;i>=0;--i)
#define pii pair<int,int>
#define pb push_back
#define vAll(v) v.begin(), v.end()
#define mAll(m) &m[0], &m[n]

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

#include <iostream>
#include <queue>
#include <unordered_set>
#include <algorithm>
#include <string>
using namespace std;

string st;
string buf;
int n;
int bn;

int func(int pos, int checker=0) {
	if (checker == bn) {
		return (n - pos);
	}
	if (pos == n) {
		return -1;
	}

	int ans = 0;
	for (int i = pos; i < n; ++i) {
		if (st[i] == buf[checker]) {
			int newAns = func(i + 1, checker + 1);
			if (newAns >= 0) newAns = max(newAns, i - pos);
			ans = max(ans, newAns);
		}
	}
	return ans;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	cin >> st;
	n = st.length();
	cin >> buf;
	bn = buf.length();

	int ans = 0;
	ans = func(0);
	cout << ans;
	return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#define MAX 200101
#define inf 2000000001

#define fora2(START,LIMIT,INCREASE) for (int i=START;i<LIMIT;i+=INCREASE)
#define ford2(START,LIMIT,INCREASE) for (int i=LIMIT-1;i>=START;i-=INCREASE)
#define fora(n) for (int i=0;i<n;++i)
#define ford(n) for (int i=n-1;i>=0;--i)
#define pii pair<int,int>
#define pb push_back
#define vAll(v) v.begin(), v.end()
#define mAll(m) &m[0], &m[n]

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

#include <iostream>
#include <queue>
#include <unordered_map>
#include <algorithm>
#include <string>
using namespace std;

string st;
string buf;
int n;
int bn;

int mas[MAX];

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	cin >> st;
	n = st.length();
	cin >> buf;
	bn = buf.length();

	for (int i = n - 1; i >= 0; --i) {
		int checker = ((i==n-1) ? n-1 : mas[i+1]-1);
		while (st[checker] != buf[i])
			--checker;
		mas[i] = checker;
	}

	int ans = 0;
	int checker = 0;

	fora(n) {
		int r = ((checker<n) ? r=mas[checker]-1 : n-1);
		ans = max(ans, r - i + 1);
		if (checker < n && buf[checker] == st[i]) ++checker;
	}

	cout << ans;
	return 0;
}


#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<vector>
using namespace std;
char a[200005],b[200005];
int c[200005],d[200005];
int main()
{
    int n,m;
    while(~scanf("%s",a))
    {
        scanf("%s",b);
        n=strlen(a);
        m=strlen(b);
        int k=0;
        int ans=0;
        for(int i=0;i<n;i++)
        {
            if(a[i]==b[k])
            {
                d[k]=i;
                k++;
            }
            if(k==m)
            {
                ans=max(ans,n-i-1);
                break;
            }
        }
        k=m-1;
        for(int i=n-1;i>=0;i--)
        {
            if(a[i]==b[k])
            {
                if(k==m-1)
                {
                    ans=max(ans,n-i-1);
                }
                else
                {
                    ans=max(ans,c[k+1]-i-1);
                }
                c[k]=i;
                k--;
            }
            if(k==-1)
            {
                ans=max(ans,i);
                break;
            }
        }
        for(int i=0;i<m-1;i++)
            ans=max(ans,c[i+1]-d[i]-1);
        printf("%d\n",ans);
    }
    return 0;
}


#include<iostream>
#include<algorithm>
#include<cstring>
#include<string>
#include<cstdio>
#include<set>
#define ll long long
using namespace std;

char s[200050];
char t[200050];
int jz[200050];
int jf[200050];
int main()
{
	scanf("%s", s);
	scanf("%s", t);
	int lens = strlen(s);
	int lent = strlen(t);
	int j = 0;
	for (int i = 0; i < lens; i++)
	{
		if (t[j] == s[i])
			jz[j++] = i;
		if (j >= lent)break;
	}
	j = lent - 1;
	for (int i = lens - 1; i >= 0; i--)
	{
		if (t[j] == s[i])
			jf[j--] = i;
		if (j < 0)break;
	}
	int ans = 0;
	for (int i = 0; i < lent-1; i++)
	{
		ans = max(ans, jf[i+1] - jz[i]-1);
	}
	ans = max(ans, jf[0]);
	ans = max(ans, lens-jz[lent - 1]-1);
	printf("%d\n", ans);
	return 0;
}


#include<iostream>
#include<algorithm>
#include<cstring>
#include<string>
#include<cstdio>
#include<set>
#define ll long long
using namespace std;

char s[200050];
char t[200050];
int jz[200050];
int jf[200050];
int main()
{
	scanf("%s", s);
	scanf("%s", t);
	int lens = strlen(s);
	int lent = strlen(t);
	int j = 0;
	for (int i = 0; i < lens; i++)
	{
		if (t[j] == s[i])
			jz[j++] = i;
		if (j >= lent)break;
	}
	j = lent - 1;
	for (int i = lens - 1; i >= 0; i--)
	{
		if (t[j] == s[i])
			jf[j--] = i;
		if (j < 0)break;
	}
	int ans = 0;
	for (int i = 0; i < lent-1; i++)
	{
		ans = max(ans, jf[i+1] - jz[i]-1);
	}
	ans = max(ans, max(jf[0],jz[0]));
	ans = max(ans, max(lens-jz[lent - 1]-1,lens-jf[lent-1]-1));
	printf("%d\n", ans);
	return 0;
}


#include<iostream>
#include<algorithm>
#include<cstring>
#include<string>
#include<cstdio>
#include<set>
#define ll long long
using namespace std;

char s[200050];
char t[200050];
int jz[200050];
int jf[200050];
int main()
{
	scanf("%s", s);
	scanf("%s", t);
	int lens = strlen(s);
	int lent = strlen(t);
	int j = 0;
	for (int i = 0; i < lens; i++)
	{
		if (t[j] == s[i])
			jz[j++] = i;
	}
	j = lent - 1;
	for (int i = lens - 1; i >= 0; i--)
	{
		if (t[j] == s[i])
			jf[j--] = i;
	}
	int ans = 0;
	for (int i = 0; i < lent; i++)
	{
		ans = max(ans, jf[i+1] - jz[i]-1);
	}
	ans = max(ans, jz[0]);
	ans = max(ans, lens-jf[lent - 1]-1);
	printf("%d\n", ans);
	return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <vector>
#include <string>
#include <cstdio>
#include <algorithm>
#include <set>
#include <map>
#include <math.h>
#include <cmath>
#include <queue>
#include <iomanip>
#include <bitset>
#include <unordered_map>
#include <stack>
#include <memory.h>
#include <list>
#include <numeric>
#include <functional>
#include <complex>
#include <cassert>
#include <clocale>
#include <fstream>

using namespace std;

long long gcd(long long a, long long b) {
	if (b == 0)
		return a;
	else
		return gcd(b, a % b);
}

int len;

vector<pair<int, int>>pos;

vector<int> prefix_function(string s) {
	int n = (int)s.length();
	vector<int> pi(n);
	for (int i = len; i < n; ++i) {
		int j = pi[i - 1];
		while (j > 0 && s[i] != s[j])
			j = pi[j - 1];
		if (s[i] == s[j])  ++j;
		pi[i] = j;
		if (pi[i] == len)
		{
			pos.push_back({ i - (2 * len),i - (len + 1) });
		}
	}
	return pi;
}

int main()
{
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#else
	//freopen("rmq.in", "r", stdin);
	//freopen("rmq.out", "w", stdout);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
#endif
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	string str1, str2;
	cin >> str1 >> str2;
	vector<int>g(str2.size());
	for (int i = (int)str2.size() - 1; i >= 0; i--)
	{
		int pos = (int)str1.size() - 1;
		if (i + 1 < (int)str2.size()) pos = g[i + 1] - 1;
		while (str1[pos] != str2[i]) pos--;
		g[i] = pos;
	}
	int ans = 0;
	int pos = 0;
	for (int i = 0; i < (int)str1.size(); i++)
	{
		int rpos = (int)str1.size() - 1;
		if (pos < (int)str2.size()) rpos = g[pos] - 1;
		ans = max(ans, rpos - i + 1);
		if (pos < (int)str2.size() && str2[pos] == str1[i])pos++;
	}
	cout << ans;
	return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <vector>
#include <string>
#include <cstdio>
#include <algorithm>
#include <set>
#include <map>
#include <math.h>
#include <cmath>
#include <queue>
#include <iomanip>
#include <bitset>
#include <unordered_map>
#include <stack>
#include <memory.h>
#include <list>
#include <numeric>
#include <functional>
#include <complex>
#include <cassert>
#include <clocale>
#include <fstream>

using namespace std;

long long gcd(long long a, long long b) {
	if (b == 0)
		return a;
	else
		return gcd(b, a % b);
}

int len;

vector<pair<int,int>>pos;

vector<int> prefix_function(string s) {
	int n = (int)s.length();
	vector<int> pi(n);
	for (int i = len; i < n; ++i) {
		int j = pi[i - 1];
		while (j > 0 && s[i] != s[j])
			j = pi[j - 1];
		if (s[i] == s[j])  ++j;
		pi[i] = j;
		if (pi[i] == len)
		{
			pos.push_back({ i - (2*len ),i - (len+1)});
		}
	}
	return pi;
}

int main()
{
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#else
	//freopen("rmq.in", "r", stdin);
	//freopen("rmq.out", "w", stdout);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
#endif
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	string str1, str2;
	cin >> str1 >> str2;
	vector<int>g(str2.size());
	for (int i = (int)str2.size()-1; i >= 0; i--)
	{
		int pos = (int)str1.size() - 1;
		if (i + 1 < (int)str2.size()) pos = g[i + 1] - 1;
		while (str1[pos] != str2[i]) pos--;
		g[i] = pos;
	}
	int ans = 0;
	int pos = 0;
	for (int i = 0; i < (int)str1.size(); i++)
	{
		int rpos = (int)str2.size()-1;
		if (pos < (int)str2.size()) rpos = g[pos] - 1;
		ans = max(ans, rpos - i + 1);
		if (pos < (int)str2.size() && str2[pos] == str1[i])pos++;
	}
	cout << ans;
	return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <vector>
#include <string>
#include <cstdio>
#include <algorithm>
#include <set>
#include <map>
#include <math.h>
#include <cmath>
#include <queue>
#include <iomanip>
#include <bitset>
#include <unordered_map>
#include <stack>
#include <memory.h>
#include <list>
#include <numeric>
#include <functional>
#include <complex>
#include <cassert>
#include <clocale>
#include <fstream>

using namespace std;

long long gcd(long long a, long long b) {
	if (b == 0)
		return a;
	else
		return gcd(b, a % b);
}

int len;

vector<pair<int,int>>pos;

vector<int> prefix_function(string s) {
	int n = (int)s.length();
	vector<int> pi(n);
	for (int i = 1; i < n; ++i) {
		int j = pi[i - 1];
		while (j > 0 && s[i] != s[j])
			j = pi[j - 1];
		if (s[i] == s[j])  ++j;
		pi[i] = j;
		if (pi[i] == len)
		{
			pos.push_back({ i - (2*len ),i - (len+1)});
		}
	}
	return pi;
}

int main()
{
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#else
	//freopen("rmq.in", "r", stdin);
	//freopen("rmq.out", "w", stdout);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
#endif
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	string str1;
	string str2;
	cin >> str1 >> str2;
	len = str2.size();
	str2 += "#";
	str2 += str1;
	vector<int> v=prefix_function(str2);
	int maxi = 0;
	for (int i = 0; i < pos.size(); i++)
	{
		maxi = max(maxi, max((int)pos[i].first , (int)str1.size()-1 - pos[i].second));
	}
	cout << maxi;
	return 0;
}


#include<cstdio>
#include<cmath>
#include<vector>
#include<cstring>
#include<string>
#include<algorithm>

using namespace std;

string s, t;
int n, m;

int bin_search(int lb, int ub)
{
	int next;
	int i;
	int match = 0;

	if (ub - lb < 2)
	{
		return lb;
	}

	next = (lb + ub) / 2;

	for (i = next; i < n; i++)
	{
		if (s[i] == t[match])
		{
			match++;
		}

		if (match == m)
		{
			break;
		}
	}

	if (match == m)
	{
		return bin_search(next, ub);
	}

	match = 0;

	for (i = 0; i < n - next; i++)
	{
		if (s[i] == t[match])
		{
			match++;
		}

		if (match == m)
		{
			break;
		}
	}

	if (match == m)
	{
		return bin_search(next, ub);
	}

	return bin_search(lb, next);
}

int main()
{
	char input[200001];
	int i;

	scanf("%s", input);
	s = input;
	n = s.size();
	scanf("%s", input);
	t = input;
	m = t.size();

	printf("%d\n", bin_search(0, n - m + 1));

	return 0;
}


#include<cstdio>
#include<cmath>
#include<vector>
#include<cstring>
#include<string>
#include<algorithm>

using namespace std;

string s, t;
int n, m;

int bin_search(int lb, int ub)
{
	int next;
	int i;
	int match = 0;

	if (ub - lb < 2)
	{
		return lb;
	}

	next = (lb + ub) / 2;

	for (i = next; i < n; i++)
	{
		if (s[i] == t[match])
		{
			match++;
		}

		if (match == m)
		{
			break;
		}
	}

	if (match == m)
	{
		return bin_search(next, ub);
	}

	match = 0;

	for (i = 0; i < n - next; i++)
	{
		if (s[i] == t[match])
		{
			match++;
		}

		if (match == m)
		{
			break;
		}
	}

	if (match == m)
	{
		return bin_search(next, ub);
	}

	return bin_search(lb, next);
}

int main()
{
	char input[200001];
	int i;
	int cand, sol;
	int first[200001], last[200001];
	int match;

	memset(first, -1, sizeof(first));

	scanf("%s", input);
	s = input;
	n = s.size();
	scanf("%s", input);
	t = input;
	m = t.size();

	sol = bin_search(0, n - m + 1);

	/*
	for (i = 0; i < n; i++)
	{
		if (first[s[i] - 'a'] == -1)
		{
			first[s[i] - 'a'] = i;
		}

		last[s[i] - 'a'] = i;
	}
	*/

	match = 0;

	for (i = 0; i < n; i++)
	{
		if (s[i] == t[match])
		{
			first[match++] = i;
		}

		if (match == m)
		{
			break;
		}
	}

	match = m - 1;

	for (i = n - 1; i >= 0; i--)
	{
		if (s[i] == t[match])
		{
			last[match--] = i;
		}

		if (match == -1)
		{
			break;
		}
	}

	for (i = 0; i < m - 1; i++)
	{
		cand = last[i + 1] - first[i] - 1;

		if (cand > sol)
		{
			sol = cand;
		}
	}

	printf("%d\n", sol);

	return 0;
}


#include<iostream>
#include<string.h>
#include<algorithm>
#define pn 200005
using namespace std;
typedef long long ll;
char ss[pn],o[pn];
ll ans1[pn],ans2[pn];
int main()
{
	scanf("%s%s",ss+1,o+1);
	ll ssl,ol;
	ssl=strlen(ss+1); ol=strlen(o+1);
	for(ll i=1,j=1;i<=ssl&&j<=ol;i++)
	{
		if(ss[i]==o[j])
		{
			ans1[j]=i;
			j++;
		}
	}
	for(ll i=ssl,j=ol;i>=1&&j>=1;i--)
	{
		if(ss[i]==o[j])
		{
			ans2[j]=i;
			j--;
		}
	}
	ll ans=max(ssl-ans1[ol],ans2[1]-1);
	for(ll i=1;i<ol;i++)
	{
		ans=max(ans,ans2[i+1]-ans1[i]-1);
	}
	printf("%lld\n",ans);
}


#include <iostream>
#include <cstdio>
#include <vector>
#include <cstring>
#include <set>
#include <algorithm>
#include <queue>
#include <string>
#include <cstring>
#include <stack>
#include <map>
#pragma warning (disable:4996)
#define INF 0x3f3f3f3f
using namespace std;
typedef long long ll;
int ans = 0;
string s, t;
void dfs(int x, int y, int m) {
	if (y == t.size()) {
		m = max(m, (int)s.size() - x);
		ans = max(ans, m);
		return;
	}
	if (x == s.size()) return;
	if (s.size() - x < t.size() - y) return;
	int l = (s.size() - x) - (t.size() - y);
	if (l <= ans && m <= ans) return;
	int i, j;
	for (i = x; i < s.size(); i++) {
		if (s[i] == t[y]) {
			dfs(i + 1, y + 1, max(i - x, m));
		}
	}
}
int main() {
	cin >> s >> t;
	dfs(0, 0, 0);
	printf("%d\n", ans);
}


#include <iostream>
#include <cstdio>
#include <vector>
#include <cstring>
#include <set>
#include <algorithm>
#include <queue>
#include <string>
#include <cstring>
#include <stack>
#include <map>
#pragma warning (disable:4996)
#define INF 0x3f3f3f3f
using namespace std;
typedef long long ll;
string s, t;
int L[200005], R[200005];
int main() {
	cin >> s >> t;
	int i, j;
	for (i = 0, j = 0; i < s.size() && j < t.size(); i++) {
		if (s[i] == t[j]) {
			L[j] = i;
			j++;
		}
	}
	for (i = s.size() - 1, j = t.size() - 1; i >= 0 && j >= 0; i--) {
		if (s[i] == t[j]) {
			R[j] = i;
			j--;
		}
	}
	int ans = 0;
	for (i = 0; i < t.size(); i++) {
		if (i == 0)
			ans = R[i];
		else ans = max(R[i] - L[i - 1] - 1, ans);
	}
	ans = max(ans, (int)s.size() - L[t.size() - 1] - 1);
	printf("%d\n", ans);
	return 0;
}


#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main() {
	string s, t;
	cin >> s >> t;

	int n = s.length(), m = t.length();

	int* firsts = new int[m];
	int* lasts = new int[m];

	for (int i = 0; i < n; i++) {
		if (s[i] == t[0]) {
			firsts[0] = i;
			break;
		}
	}
	for (int i = 1; i < m; i++) {
		for (int j = firsts[i - 1] + 1; j < n; j++) {
			if (s[j] == t[i]) {
				firsts[i] = j;
				break;
			}
		}
	}

	for (int i = n - 1; i >= 0; i--) {
		if (s[i] == t[m - 1]) {
			lasts[m - 1] = i;
			break;
		}
	}
	for (int i = m - 2; i >= 0; i--) {
		for (int j = lasts[i + 1] - 1; j >= 0; j--) {
			if (s[j] == t[i]) {
				lasts[i] = j;
				break;
			}
		}
	}

	int max_d = 0;
	for (int i = 1; i < m; i++) {
		int d = lasts[i] - firsts[i - 1] - 1;
		max_d = max(max_d, d);
	}

	max_d = max(max_d, lasts[0]);
	max_d = max(max_d, n - firsts[m - 1] - 1);

	cout << max_d << "\n";

	return 0;
}


#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
using namespace std;

const int maxn=200000+5;

int main()
{
    string s1,s2;
    cin>>s1>>s2;
    if(s1.size()==s2.size())
        cout<<"0"<<endl;
    else
    {
        int cnt=0,ans[maxn];
        for(int i=0,j=0;i<s2.size() && j<s1.size();j++)
        {
            if(s2[i]==s1[j])
            {
                ans[i]=j;
                if(i>0)
                {
                    for(int k=ans[i-1]+1;k<ans[i];k++)
                    {
                        if(s2[i-1]==s1[k])
                            ans[i-1]=k;
                    }
                }
                i++;
            }
        }
        int length=ans[0];
        for(int i=1;i<s2.size();i++)
        {
            int l=ans[i]-ans[i-1]-1;
            length=max(length,l);
        }
        length=max(length,(int)(s1.size()-ans[s2.size()-1]-1));
        cout<<length<<endl;
    }
    //system("pause");

    return 0;
}


#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
using namespace std;

const int maxn=200000+5;

int main()
{
    string s1,s2;
    cin>>s1>>s2;
    if(s1.size()==s2.size())
        cout<<"0"<<endl;
    else
    {
        int cnt=0,ans1[maxn],ans2[maxn];
        for(int i=0,j=0;i<s2.size() && j<s1.size();j++)
        {
            if(s2[i]==s1[j])
            {
                ans1[i]=j;
                i++;
            }
        }
        for(int i=s1.size()-1,j=s2.size()-1;i>=0 && j>=0;i--)
        {
            if(s2[j]==s1[i])
            {
                ans2[j]=i;
                j--;
            }
        }
        int length=max((int)s1.size()-1-ans1[s2.size()-1],ans2[0]);
        for(int i=0;i<s2.size()-1;i++)
            length=max(length,ans2[i+1]-ans1[i]-1);
        cout<<length<<endl;
    }
    //system("pause");

    return 0;
}


#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
const int N =2e5+10;
char s1[N],s2[N];
int l[N],r[N];

int main()
{
	int ans=0;
	scanf("%s%s",s1,s2);
	int len1=strlen(s1);
	int len2=strlen(s2);
	int j=0;

	for(int i=0;i<len1&&j<len2;i++)
	{
		if(s1[i]==s2[j])
		{
			l[j]=i;
			j++;
		}
	}

	j=len2-1;
	for(int i=len1-1;i>=0&&j>=0;i--)
	{
		if(s1[i]==s2[j])
		{
			r[j]=i;
			j--;
		}
	}
	ans=max(r[0],len1-l[len2-1]-1);
	for(int i=1;i<len2;i++)
	{
		ans=max(ans,r[i]-l[i-1]-1);
	}
	printf("%d\n",ans);
	return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;

int main()
{
    string s, t;
    int max = 0, current;
    cin >> s >> t; // t is substr of s
    int l[200000], r[200000];

    //left side
    int j = 0;
    for (int i = 0; i < s.size(); i++) {
        if (t[j] == s[i]) {
            l[j++] = i;
            if (j == t.size())
                break;
        }
    }

    //right side
    j = t.size() - 1;
    for (int i = s.size() - 1; i >= 0; i--) {
        if (t[j] == s[i]) {
            r[j--] = i;
            if (j == -1)
                break;
        }
    }

    int Penguin = 0;
    Penguin = std::max(Penguin, r[0]);

    for (int j = 0; j < t.size(); j++) {
        Penguin = std::max(Penguin, r[j] - l[j - 1] - 1);
    }

    Penguin = std::max(Penguin, (int)s.size() - l[t.size() - 1] - 1);

    cout << Penguin << endl;
}


#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
//#include <tchar.h>
//#include <intrin.h>

#define LL long long
#define MOD 998244353
#define INF 2000000000
#define LINF 9000000000000000000

using namespace std;

const int N = 2e5 + 10;

int dp[N];
int dp2[N];

int main()
{
	string s, s1;
	int n1, n2;
	cin >> s >> s1;
	n1 = s.length(), n2 = s1.length();

	s = '#' + s;

	for (int i = 1;i <= n1;i++)
		dp[i] = dp[i - 1] < n2 ? dp[i - 1] + (s[i] == s1[dp[i - 1]]) : dp[i - 1];

	for (int i = n1;i >= 1;i--)
		dp2[i] = dp2[i + 1] < n2 ? dp2[i + 1] + (s[i] == s1[n2 - dp2[i + 1] - 1]) : dp2[i + 1];

	int l = 1, r = 1;
	int ans = 0;

	while (r <= n1) {

		if (dp[l - 1] + dp2[r + 1] >= n2) ans = max(ans, r - l + 1), r++;
		else l++;

		while (r < l) r++;
	}
	printf("%d\n", ans);
}


#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <functional>
#include <limits.h>
#include <set>
#include <map>
#include <tuple>
using namespace std;

#define ll long long
#define ull unsigned long long
#define rep(i,N) for (ll i=0;i<N;i++)
#define loop(i,N,M) for(ll i=N;i<M;i++)
#define MAX(v) *max_element(v.begin(),v.end())
#define MIN(v) *min_element(v.begin(),v.end())
#define SORTL2S(type,v) sort(v.begin(),v.end(),greater<type>())
#define SORTS2L(type,v) sort(v.begin(),v.end())
#define SORTMF(v,func) sort(v.begin(),v.end(),func)

ll debugFlag = false;
template<typename T> void debug(T&);
template<typename T> void debug(T&, bool);
template<typename T> void debug(vector<T>&);
template<typename T> void debug(vector<T>&, bool);
template<typename T, typename U> void debug(pair<T, U>&);
template<typename T, typename U> void debug(pair<T, U>&, bool);

template<typename T>
void debug(T& obj) {
	debug(obj, true);
}

template<typename T>
void debug(T& obj, bool lnFlag) {
	if (!debugFlag) return;
	cout << obj;
	if (lnFlag) cout << endl;
}

template<typename T>
void debug(vector<T>& obj) {
	debug(obj, true);
}

template<typename T>
void debug(vector<T>& obj, bool lnFlag) {
	if (!debugFlag) return;
	cout << "[";
	rep(i, obj.size()) {
		if (i != 0) cout << ",";
		debug(obj[i], false);
	}
	cout << "]";
	if (lnFlag) cout << endl;
}

template<typename T, typename U>
void debug(pair<T, U>& obj) {
	debug(obj, true);
}

template<typename T, typename U>
void debug(pair<T, U>& obj, bool lnFlag) {
	if (!debugFlag) return;
	cout << "(";
	debug(obj.first, false);
	cout << ",";
	debug(obj.second, false);
	cout << ")";
	if (lnFlag) cout << endl;
}

ll GCD(ll x, ll y) {
	ll tmp;
	if (y > x) {
		tmp = x;
		x = y;
		y = tmp;
	}
	while (x%y != 0) {
		tmp = y;
		y = x % y;
		x = tmp;
	}
	return y;
}

void solve() {
	string S, T;
	cin >> S >> T;

	vector<vector<ll>> record(26, vector<ll>());

	rep(i, S.size()) {
		record[S[i] - 'a'].emplace_back(i);
	}

	debug(record);

	vector<ll> sel(T.size());

	rep(i, sel.size()) {
		if (i == 0) sel[i] = record[T[i] - 'a'][0];
		else sel[i] = *lower_bound(record[T[i] - 'a'].begin(), record[T[i] - 'a'].end(), sel[i - 1] + 1);
	}

	debug(sel);

	ll ans = 0;

	ans = max(ans, sel[0]);
	ans = max(ans, S.size() - sel[sel.size() - 1]-1);
	rep(i, T.size() - 1) {
		ans = max(ans, sel[i + 1] - sel[i] - 1);
	}

	for (ll i = sel.size() - 1; i >= 0; i--) {

		if (i == sel.size() - 1) sel[i] = record[T[i] - 'a'][record[T[i] - 'a'].size() - 1];
		else {
			auto itr = lower_bound(record[T[i] - 'a'].begin(), record[T[i] - 'a'].end(), sel[i + 1]);
			itr--;
			sel[i] = *itr;
		}

		if (i == 0) {
			ans = max(ans, sel[0]);
		}
		else {
			ans = max(ans, sel[i] - sel[i - 1] - 1);
		}
	}

	cout << ans;

}

int main(int argc, char* argv[]) {
	if (argc == 2 && string(argv[1]) == "debug") debugFlag = true;
	solve();
	cout << endl;
	return 0;
}


#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <math.h>

using namespace std;

int main() {
	string s, t;
	cin >> s >> t;
	int n = s.size();
	int m = t.size();

	vector<int> pref(n + 2);
	int ind = 0;
	for (int i = 0; i < n; ++i) {
		if (s[i] == t[ind])
			++ind;
		pref[i + 1] = ind;
	}
	pref[n + 1] = pref[n];

	vector<int> suff(n + 2);
	ind = m - 1;
	for (int i = n - 1; i >= 0; --i) {
		if (s[i] == t[ind])
			--ind;
		suff[i + 1] = m - 1 - ind;
	}
	suff[0] = suff[1];
	/*
	for (auto &a : pref)
		cout << a << ' ';
	cout << endl;
	for (auto &a : suff)
		cout << a << ' ';
	cout << endl;
	*/
	int ans = 0;
	for (int i = 0, j = 0; i <= n; ++i) {
		int v = m - pref[i];
		while (j <= n) {
			if (suff[j + 1] >= v)
				++j;
			else
				break;
		}
		//cout << "i,j: " << i << ',' << j << endl;
		ans = max(ans, j - i - 1);
	}

	cout << ans;
	return 0;
}


#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
	string s, t;
	cin >> s >> t;
	int n = s.size(), m = t.size();
	vector<int> suff(n + 1);
	for (int i = n - 1, j = m - 1; i >= 0; --i) {
		j -= (s[i] == t[j]);
		suff[i] = m - 1 - j;
	}
	int ind = 0;
	for (; ind < n && suff[ind + 1] >= m; ++ind);
	int ans = ind;
	for (int i = 0, j = 0; i < n; ++i) {
		j += (j < m && s[i] == t[j]);
		for (; ind < n && suff[ind + 1] >= m - j; ++ind);
		ans = max(ans, ind - i - 1);
	}
	cout << ans;
	return 0;
}


#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<map>
#include<queue>
#include<vector>
#include<string>
#define ll long long
using namespace std;
char a[250000];
char b[250000];
int l[250000];
int r[250000];
int main()
{
	scanf("%s",a+1);
	scanf("%s",b+1);
	int len1=strlen(a+1);
	int len2=strlen(b+1);
	int t=1;
	for(int i=1;i<=len1;i++)
	{
		if(a[i]==b[t]&&t<=len2)
		{
			l[t]=i;
			t++;
		}
	}
	t=len2;
	for(int i=len1;i>=1;i--)
	{
		if(a[i]==b[t]&&t>=1)
		{
			r[t]=i;
			t--;
		}
	}
	int ans=0;
	ans=max(r[1]-1,len1-l[len2]);
	for (int i=2;i<=len2;i++)
		ans=max(ans,r[i]-l[i-1]-1);
		printf("%d\n",ans);
}


#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<set>
#include<string>
#include<cmath>
#include<map>
#include<bitset>
#include<utility>
#ifdef LOCAL
#include"file.h"
#endif

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
const double eps = 1e-6;
const double Pi = 3.1415926535897932;
const int dir[4][2] = { -1,0,1,0,0,-1,0,1 };
//const int dir[8][2] = { -2,-1,-2,1,2,-1,2,1,-1,2,-1,-2,1,2,1,-2 };

const int maxn = 2e5 + 5;

char s[maxn], t[maxn];

int f[2][maxn];

int n, m;
int main() {
#ifdef LOCAL
	fileopen();
#endif

	scanf("%s%s", s + 1, t + 1);
	n = strlen(s + 1);
	m = strlen(t + 1);

	int p = 1;
	for (int i = 1; i <= m; i++) {
		while (1) {
			if (s[p] == t[i])break;
			p++;
		}
		f[0][i] = p;
		p++;
	}
	p = n;
	for (int i = m; i >= 1; i--) {
		while (1){
			if (s[p] == t[i])break;
			p--;
		}
		f[1][i] = p;
		p--;
	}
	int ans = max(f[1][1] - 1, n - f[0][m]);
	for (int i = 1; i <= m; i++) {
		ans = max(ans, f[1][i] - f[0][i]);
	}
	for (int i = 1; i < m; i++) {
		ans = max(ans, f[0][i - 1] - f[0][i] - 1);
		ans = max(ans, f[1][i - 1] - f[1][i] - 1);
	}

	printf("%d\n", ans);

#ifdef LOCAL
	fileclose();
#endif
	return 0;
}


#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<set>
#include<string>
#include<cmath>
#include<map>
#include<bitset>
#include<utility>
#ifdef LOCAL
#include"file.h"
#endif

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
const double eps = 1e-6;
const double Pi = 3.1415926535897932;
const int dir[4][2] = { -1,0,1,0,0,-1,0,1 };
//const int dir[8][2] = { -2,-1,-2,1,2,-1,2,1,-1,2,-1,-2,1,2,1,-2 };

const int maxn = 2e5 + 5;

char s[maxn], t[maxn];

int f[2][maxn];

int n, m;
int main() {
#ifdef LOCAL
	fileopen();
#endif

	scanf("%s%s", s + 1, t + 1);
	n = strlen(s + 1);
	m = strlen(t + 1);

	int p = 1;
	for (int i = 1; i <= m; i++) {
		while (1) {
			if (s[p] == t[i])break;
			p++;
		}
		f[0][i] = p;
	}
	p = n;
	for (int i = m; i >= 1; i--) {
		while (1){
			if (s[p] == t[i])break;
			p--;
		}
		f[1][i] = p;
	}
	int ans = max(f[1][1]-1, m-f[0][m]);
	for (int i = 1; i <= m; i++) {
		ans = max(ans, f[1][i] - f[0][i]);
	}
	printf("%d\n", ans);

#ifdef LOCAL
	fileclose();
#endif
	return 0;
}


#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<set>
#include<string>
#include<cmath>
#include<map>
#include<bitset>
#include<utility>
#ifdef LOCAL
#include"file.h"
#endif

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
const double eps = 1e-6;
const double Pi = 3.1415926535897932;
const int dir[4][2] = { -1,0,1,0,0,-1,0,1 };
//const int dir[8][2] = { -2,-1,-2,1,2,-1,2,1,-1,2,-1,-2,1,2,1,-2 };

const int maxn = 2e5 + 5;

char s[maxn], t[maxn];

int f[2][maxn];

int n, m;
int main() {
#ifdef LOCAL
	fileopen();
#endif

	scanf("%s%s", s + 1, t + 1);
	n = strlen(s + 1);
	m = strlen(t + 1);

	int p = 1;
	for (int i = 1; i <= m; i++) {
		while (1) {
			if (s[p] == t[i])break;
			p++;
		}
		f[0][i] = p;
		p++;
	}
	p = n;
	for (int i = m; i >= 1; i--) {
		while (1){
			if (s[p] == t[i])break;
			p--;
		}
		f[1][i] = p;
		p--;
	}
	int ans = max(f[1][1] - 1, n - f[0][m]);
	for (int i = 1; i < m; i++) {
		ans = max(ans, f[1][i+1] - f[0][i]-1);
	}

	printf("%d\n", ans);

#ifdef LOCAL
	fileclose();
#endif
	return 0;
}


#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<set>
#include<string>
#include<cmath>
#include<map>
#include<bitset>
#include<utility>
#ifdef LOCAL
#include"file.h"
#endif

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
const double eps = 1e-6;
const double Pi = 3.1415926535897932;
const int dir[4][2] = { -1,0,1,0,0,-1,0,1 };
//const int dir[8][2] = { -2,-1,-2,1,2,-1,2,1,-1,2,-1,-2,1,2,1,-2 };

const int maxn = 2e5 + 5;

char s[maxn], t[maxn];

int f[2][maxn];

int n, m;
int main() {
#ifdef LOCAL
	fileopen();
#endif

	scanf("%s%s", s + 1, t + 1);
	n = strlen(s + 1);
	m = strlen(t + 1);

	int p = 1;
	for (int i = 1; i <= m; i++) {
		while (1) {
			if (s[p] == t[i])break;
			p++;
		}
		f[0][i] = p;
		p++;
	}
	p = n;
	for (int i = m; i >= 1; i--) {
		while (1){
			if (s[p] == t[i])break;
			p--;
		}
		f[1][i] = p;
		p--;
	}
	int ans = max(f[1][1]-1, n-f[0][m]);
	for (int i = 1; i <= m; i++) {
		ans = max(ans, f[1][i] - f[0][i]);
	}
	printf("%d\n", ans);

#ifdef LOCAL
	fileclose();
#endif
	return 0;
}


#include<stdio.h>
#include<math.h>
#include<string.h>
#include<algorithm>
#define ll long long
using namespace std;
const int mod=1e9+7;
const int maxm=2e5+10;
char s[maxm],t[maxm];
int fir[maxm],las[maxm];
int main()
{
	scanf("%s%s",s+1,t+1);
	int len1=strlen(s+1);
	int len2=strlen(t+1);
	for(int i=1,j=1;i<=len1&&j<=len2;i++)
	{
		if(s[i]==t[j])
		{
			fir[j]=i;
			j++;
		}
	}
	for(int i=len1,j=len2;i>=1&&j>=1;i--)
	{
		if(s[i]==t[j])
		{
			las[j]=i;
			j--;
		}
	}
	int mmax=0;
	for(int i=1;i<=len2-1;i++)
	{
		mmax=max(mmax,las[i+1]-fir[i]-1);
	}
	mmax=max(mmax,las[1]-1);
	mmax=max(mmax,len1-fir[len2]);
	printf("%d\n",mmax);
	return 0;
}


#include<map>
#include<stack>
#include<cmath>
#include<queue>
#include<string>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<iostream>
#include<algorithm>
using namespace std;
const int maxl=200000+10;
int str[maxl];
int main()
{
   string s1,s2;
   cin>>s1>>s2;
   int len1=s1.size();
   int len2=s2.size();
   while(len1&&len2)
   {
       if(s1[len1-1]==s2[len2-1])
       {
           str[len2]=len1;
           len2--;
       }
       len1--;
   }
   int ans=str[1]-1;
   int n=1;
   str[s2.size()+1]=s1.size()+1;
   for(int i=0;i<s1.size();i++)
   {
       if(s1[i]==s2[n-1])
       {
        ans=max(ans,str[n+1]-i-1-1);
        n++;
       }
   }
   cout<<ans<<endl;
    return 0;
}


#include<iostream>
#include<stack>
#include<string>
#include<map>
#include<algorithm>
#include<vector>
#include<queue>
#include<list>
#include<ctime>
#include<math.h>
#include<functional>
#include<cstring>
#include<iomanip>
#include<set>
#include<utility>
#include<limits.h>
#include<stdio.h>
#define lowbit(x) (x)&(-x)

typedef long long ll;
//
using namespace std;
const int maxn = 2e5+ 10;
const int maxm = 1e5 + 10;
const ll mod = 1e9+7;
const int inf = 0x3fffffff;

/*ll gcd(ll a, ll b)//���Լ��
{
	return b == 0 ? a : gcd(b, a%b);
}
ll lcm(ll a, ll b)
{
return a / gcd(a, b)*b;
}
ll fast_pow(ll a, ll k)//������
{
	ll ans = 1;
	a = a%mod;
	while (k != 0)
	{
		if (k & 1) ans = (ans*a) % mod;
		k >>= 1;
	a = (a*a) % mod;
	}
	return ans;
}
ll C(ll n, ll m)//������ļ���
{
	ll ans = 1;
	for (int i = 1;i <= m;i++)
		ans = (ans*(n - m + i) / i)%mod;
	return ans%mod;
}
bool is_prime(ll x)//�����ж�
{
if (x == 2 || x == 3) return true;
if (x % 6 != 1 && x % 6 != 5) return false;
ll temp = sqrt(1.0*x);
for (ll i = 5;i <= temp;i += 6)
if (x%i == 0 || x % (i + 2) == 0) return false;
return true;
}
int prime[maxm], pnum = 0;//������pnum������
bool p[maxm] = { 0 };//�����ɸ������Ϊtrue
void Find_Prime()//�����ɸѡ��������һ���������Ͱ����ı���ȫ��ɸ��
{
for (int i = 2;i < maxm;i++)
{
if (p[i] == false)//����һ����һ�������ж�������
{
prime[pnum++] = i;
for (int j = i + i;j < maxm;j += i)//ɸ�������ı���
p[j] = true;
}
}
}

/*void Exgcd(ll a, ll b, ll &x, ll &y) {
	if (!b) x = 1, y = 0;
	else Exgcd(b, a % b, y, x), y -= a / b * x;
}//x��a��mod b�µ���Ԫ
ll CRT(int a[],int m[],int n)
{
ll M=1,ans=0,t,x,y;
for(int i=0; i<n; i++)
{
M*=m[i];///MΪ�����˻�
}
for(int i=0; i<n; i++)
{
t=M/m[i];///����mi�����n-1�������˻�
Exgcd(t,m[i],x,y);///����Ԫ������չŷ�����ת����t*ti+m[i]*y=1����ti
ans=(ans+a[i]*x*t)%M;
}
return (ans+M)%M;
}*/

char s[maxn], t[maxn];
int vis[maxn], vs[maxn];
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	cin >> s + 1 >> t + 1;
	int j = 1;
	int n = strlen(s + 1);
	int m = strlen(t + 1);
	for (int i = 1;i <= n&&j <= m;i++)
		if (s[i] == t[j])
			vis[j] = i, j++;
	j = m;
	for (int i = n;i >= 1&&j >= 1;i--)
		if (s[i] == t[j])
			vs[j] = i, j--;
	int ans = max(vs[1] - 1, n - vis[m]);
	for (int i = 1;i <= m;++i)
		ans = max(ans, vs[i] - vis[i - 1] - 1);
	cout << ans;
	return ~~(0 - 0);
}


#include<iostream>
#include<stack>
#include<string>
#include<map>
#include<algorithm>
#include<vector>
#include<queue>
#include<list>
#include<ctime>
#include<math.h>
#include<functional>
#include<cstring>
#include<iomanip>
#include<set>
#include<utility>
#include<limits.h>
#include<stdio.h>
#define lowbit(x) (x)&(-x)

typedef long long ll;
//
using namespace std;
const int maxn = 2e5+ 10;
const int maxm = 1e5 + 10;
const ll mod = 1e9+7;
const int inf = 0x3fffffff;

/*ll gcd(ll a, ll b)//���Լ��
{
	return b == 0 ? a : gcd(b, a%b);
}
ll lcm(ll a, ll b)
{
return a / gcd(a, b)*b;
}
ll fast_pow(ll a, ll k)//������
{
	ll ans = 1;
	a = a%mod;
	while (k != 0)
	{
		if (k & 1) ans = (ans*a) % mod;
		k >>= 1;
	a = (a*a) % mod;
	}
	return ans;
}
ll C(ll n, ll m)//������ļ���
{
	ll ans = 1;
	for (int i = 1;i <= m;i++)
		ans = (ans*(n - m + i) / i)%mod;
	return ans%mod;
}
bool is_prime(ll x)//�����ж�
{
if (x == 2 || x == 3) return true;
if (x % 6 != 1 && x % 6 != 5) return false;
ll temp = sqrt(1.0*x);
for (ll i = 5;i <= temp;i += 6)
if (x%i == 0 || x % (i + 2) == 0) return false;
return true;
}
int prime[maxm], pnum = 0;//������pnum������
bool p[maxm] = { 0 };//�����ɸ������Ϊtrue
void Find_Prime()//�����ɸѡ��������һ���������Ͱ����ı���ȫ��ɸ��
{
for (int i = 2;i < maxm;i++)
{
if (p[i] == false)//����һ����һ�������ж�������
{
prime[pnum++] = i;
for (int j = i + i;j < maxm;j += i)//ɸ�������ı���
p[j] = true;
}
}
}

/*void Exgcd(ll a, ll b, ll &x, ll &y) {
	if (!b) x = 1, y = 0;
	else Exgcd(b, a % b, y, x), y -= a / b * x;
}//x��a��mod b�µ���Ԫ
ll CRT(int a[],int m[],int n)
{
ll M=1,ans=0,t,x,y;
for(int i=0; i<n; i++)
{
M*=m[i];///MΪ�����˻�
}
for(int i=0; i<n; i++)
{
t=M/m[i];///����mi�����n-1�������˻�
Exgcd(t,m[i],x,y);///����Ԫ������չŷ�����ת����t*ti+m[i]*y=1����ti
ans=(ans+a[i]*x*t)%M;
}
return (ans+M)%M;
}*/
vector<int> res;
string s1, s2;
int Next[maxn];
void get_next()//��next���飬��s2���Լ����Լ�ƥ��Ĺ���
{
	Next[0] = -1;
	int k = -1, j = 0;
	while (j < s2.size())
	{
		if (k == -1 || s2[j] == s2[k]) Next[++j] = ++k;
		else k = Next[k];
	}
}
void kmp()//s1��s2ƥ����̣�������ûʲô��ͬ
{
	int i = 0, j = 0;
	while (i < s1.size())
	{
		if (j == -1 || s1[i] == s2[j]) i++, j++;
		else j = Next[j];
		if (j == s2.size())
			j = Next[j], res.push_back(i-s2.size()+1);//���ƥ�䣬j���������ôj=next[j]����ȥ����ƥ��
	}
}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	cin >> s1 >> s2;
	get_next();
	kmp();
	int maxnum = 0;
	for (int i = 0;i < res.size();i++)
		maxnum = max(res[i] - 1, max(maxnum, (int)s1.size() - (res[i] - 1 + (int)s2.size())));
	cout << maxnum;
	return ~~(0 - 0);
}


#include<iostream>
#include<stack>
#include<string>
#include<map>
#include<algorithm>
#include<vector>
#include<queue>
#include<list>
#include<ctime>
#include<math.h>
#include<functional>
#include<cstring>
#include<iomanip>
#include<set>
#include<utility>
#include<limits.h>
#include<stdio.h>
#define lowbit(x) (x)&(-x)

typedef long long ll;
//
using namespace std;
const int maxn = 2e5+ 10;
const int maxm = 1e5 + 10;
const ll mod = 1e9+7;
const int inf = 0x3fffffff;

/*ll gcd(ll a, ll b)//���Լ��
{
	return b == 0 ? a : gcd(b, a%b);
}
ll lcm(ll a, ll b)
{
return a / gcd(a, b)*b;
}
ll fast_pow(ll a, ll k)//������
{
	ll ans = 1;
	a = a%mod;
	while (k != 0)
	{
		if (k & 1) ans = (ans*a) % mod;
		k >>= 1;
	a = (a*a) % mod;
	}
	return ans;
}
ll C(ll n, ll m)//������ļ���
{
	ll ans = 1;
	for (int i = 1;i <= m;i++)
		ans = (ans*(n - m + i) / i)%mod;
	return ans%mod;
}
bool is_prime(ll x)//�����ж�
{
if (x == 2 || x == 3) return true;
if (x % 6 != 1 && x % 6 != 5) return false;
ll temp = sqrt(1.0*x);
for (ll i = 5;i <= temp;i += 6)
if (x%i == 0 || x % (i + 2) == 0) return false;
return true;
}
int prime[maxm], pnum = 0;//������pnum������
bool p[maxm] = { 0 };//�����ɸ������Ϊtrue
void Find_Prime()//�����ɸѡ��������һ���������Ͱ����ı���ȫ��ɸ��
{
for (int i = 2;i < maxm;i++)
{
if (p[i] == false)//����һ����һ�������ж�������
{
prime[pnum++] = i;
for (int j = i + i;j < maxm;j += i)//ɸ�������ı���
p[j] = true;
}
}
}

/*void Exgcd(ll a, ll b, ll &x, ll &y) {
	if (!b) x = 1, y = 0;
	else Exgcd(b, a % b, y, x), y -= a / b * x;
}//x��a��mod b�µ���Ԫ
ll CRT(int a[],int m[],int n)
{
ll M=1,ans=0,t,x,y;
for(int i=0; i<n; i++)
{
M*=m[i];///MΪ�����˻�
}
for(int i=0; i<n; i++)
{
t=M/m[i];///����mi�����n-1�������˻�
Exgcd(t,m[i],x,y);///����Ԫ������չŷ�����ת����t*ti+m[i]*y=1����ti
ans=(ans+a[i]*x*t)%M;
}
return (ans+M)%M;
}*/

char s[maxn], t[maxn];
int vis[maxn], vs[maxn];
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	cin >> s + 1 >> t + 1;
	int j = 1;
	int n = strlen(s + 1);
	int m = strlen(t + 1);
	for (int i = 1;i <= n&&j <= m;i++)
		if (s[i] == t[j])
			vis[j] = i, j++;
	j = m;
	for (int i = n;i >= 1&&j >= 1;i--)
		if (s[i] == t[j])
			vs[j] = i, j--;
	int ans = max(vis[1] - 1, n - vis[m]);
	ans = max(vs[1] - 1, ans);
	ans = max(n - vs[m], ans);
	for (int i = 1;i <= m;++i)
		ans = max(ans, vs[i] - vis[i - 1] - 1);
	cout << ans;
	return ~~(0 - 0);
}


#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <string>
#define max(a,b) (a>b?a:b)
typedef unsigned long long ull;
const int maxn = 2e5 + 1;
using namespace std;
int arr[maxn];

int main() {
	string a, b;
	arr[0] = -1;
	int k = 1;
	cin >> a >> b;
	for (int i = 0, j = 0; i < a.size(); i++) {
		if (j < b.size() && a[i] == b[j]) {
			arr[k++] = i;
			j++;
		}
	}
	int ans = 0;
	for (int i = a.size() - 1, j = 0; i >= 0; i--) {
		ans = max(ans, i - arr[b.size() - j]);
		if (j < b.size() && a[i] == b[b.size() - 1 - j]) j++;
	}
	cout << ans << endl;
}


#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <string>
#define max(a,b) (a>b?a:b)
typedef unsigned long long ull;
const int maxn = 2e5 + 1;
using namespace std;
int fr[maxn], ba[maxn];
int main() {
	string a, b;
	cin >> a >> b;
	for (int i = 0, j = 0; i < a.size(); i++) {
		if (j < b.size() && a[i] == b[j]) fr[j++] = i;
	}
	for (int i = a.size() - 1, j = b.size() - 1; i >= 0; i--) {
		if (j >= 0 && a[i] == b[j]) ba[j--] = i;
	}
	int ans1 = max(fr[0], a.size() - 1 - fr[b.size() - 1]);
	int ans2 = max(ba[0], a.size() - 1 - ba[b.size() - 1]);
	int ans = max(ans1, ans2);
	for (int i = 1; i < b.size(); i++) {
		ans = max(ans, ba[i] - fr[i - 1] - 1);
	}
	cout << ans << endl;
}


#include <iostream>
#include <string>
#define max(a,b) (a>b?a:b)
typedef unsigned long long ull;
const int maxn = 2e5;
using namespace std;
int arr[maxn];
int main() {
	string a, b;
	int k = 0;
	cin >> a >> b;
	for (int i = 0, j = 0; i < a.size(); i++) {
		if (k < b.size() && a[i] == b[j]) {
			arr[k++] = i;
			j++;
		}
	}
	int ans = 0;
	for (int i = a.size() - 1, j = 0; i >= 0; i--) {
		ans = max(ans, i - arr[b.size() - 1 - j]);
		if (j < b.size() && a[i] == b[b.size() - 1 - j]) j++;
	}
	cout << ans << endl;
}


#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <string>
#define max(a,b) (a>b?a:b)
typedef unsigned long long ull;
const int maxn = 2e5 + 1;
using namespace std;

int main() {
	string a, b;
	cin >> a >> b;
	int fr[200], ba[200];
	for (int i = 0, j = 0; i < a.size(); i++) {
		if (j < b.size() && a[i] == b[j]) fr[j++] = i;
	}
	for (int i = a.size() - 1, j = b.size() - 1; i >= 0; i--) {
		if (j >= 0 && a[i] == b[j]) ba[j--] = i;
	}
	int ans1 = max(fr[0], a.size() - 1 - fr[b.size() - 1]);
	int ans2 = max(ba[0], a.size() - 1 - ba[b.size() - 1]);
	int ans = max(ans1, ans2);
	for (int i = 1; i < b.size(); i++) {
		ans = max(ans, ba[i] - fr[i - 1] - 1);
	}
	cout << ans << endl;
}


#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <string>
using namespace std;
const int maxn = 2e5 + 7;
typedef long long ll;

string a;
string b;
int f[maxn];

int main() {
	cin >> a >> b;
	f[0] = -1;
	int k = 1;
	for (int i = 0, j = 0; i < a.size(); i++) {
		if (j < b.size() && a[i] == b[j]) {
			f[k++] = i;
			j++;
		}
	}
	int ans = 0;
	for (int i = a.size() - 1, j = 0; i >= 0; i--) {
		ans = max(ans, i - f[b.size() - j]);
		if (j < b.size() && a[i] == b[b.size() - j - 1]) {
			j++;
		}
	}
	cout << ans << endl;
	return 0;
}


#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <climits>
#include <iostream>
#include <functional>

#define MY_LOG 0
#define mylog(form, arg) if (MY_LOG) printf(form, arg);
typedef long long LL;

int main() {
	//freopen("in.txt", "r", stdin);
	char b[200000 + 1];
	scanf("%200000s", b);
	std::string s(b);
	scanf("%200000s", b);
	std::string t(b);
	int ans = 0;
	int ns = s.size();
	int nt = t.size();
	std::vector<int> p(1 + ns);
	p[0] = 0;
	for (int pl = 1; pl <= s.size(); ++pl) {
		p[pl] = p[pl - 1];
		if (p[pl - 1] < nt && t[p[pl - 1]] == s[pl - 1]) {
			++p[pl];
		}
	}
	std::reverse(s.begin(), s.end());
	std::reverse(t.begin(), t.end());
	std::vector<int> su(1 + ns);
	su[0] = 0;
	for (int sl = 1; sl <= s.size(); ++sl) {
		su[sl] = su[sl - 1];
		if (su[sl - 1] < nt && t[su[sl - 1]] == s[sl - 1]) {
			++su[sl];
		}
	}
	int l = 0, r = s.size();
	while (r > l + 1) {
		int m = (l + r) / 2;
		bool ans = false;
		for (int b = 0; b <= s.size() - m; ++b) {
			if (p[b] + su[ns - (b + m)] >= nt) {
				ans = true;
				break;
			}
		}
		if (ans) {
			l = m;
		}
		else {
			r = m;
		}
	}
	printf("%d", l);
	return 0;
}


#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <climits>
#include <iostream>
#include <functional>

#define MY_LOG 0
#define mylog(form, arg) if (MY_LOG) printf(form, arg);
typedef long long LL;

int main() {
	//freopen("in.txt", "r", stdin);
	char b[200 + 1];
	scanf("%200s", b);
	std::string s(b);
	scanf("%200s", b);
	std::string t(b);
	int ans = 0;
	int ns = s.size();
	int nt = t.size();
	std::vector<int> p(1 + ns);
	p[0] = 0;
	for (int pl = 1; pl <= s.size(); ++pl) {
		p[pl] = p[pl - 1];
		if (p[pl - 1] < nt && t[p[pl - 1]] == s[pl - 1]) {
			++p[pl];
		}
	}
	std::reverse(s.begin(), s.end());
	std::reverse(t.begin(), t.end());
	std::vector<int> su(1 + ns);
	su[0] = 0;
	for (int sl = 1; sl <= s.size(); ++sl) {
		su[sl] = su[sl - 1];
		if (su[sl - 1] < nt && t[su[sl - 1]] == s[sl - 1]) {
			++su[sl];
		}
	}
	int l = 0, r = s.size();
	while (r > l + 1) {
		int m = (l + r) / 2;
		bool ans = false;
		for (int b = 0; b <= s.size() - m; ++b) {
			if (p[b] + su[ns - (b + m)] >= nt) {
				ans = true;
				break;
			}
		}
		if (ans) {
			l = m;
		}
		else {
			r = m;
		}
	}
	printf("%d", l);
	return 0;
}


#include<iostream>
#include<cstring>
#include<cstdlib>
#include<cstdio>
#include<cmath>
#include<string>
#include<algorithm>
using namespace std;
typedef long long ll;
#define MOD 1000000007

char str[100010];
int main(){
	cin>>str;
	int len = strlen(str);
	ll ans = 1;
	int t;
	for(int i = 0;i<len;i++){
		if(str[i]>='0'&&str[i]<='9')
			t = str[i] - '0';
		else if(str[i]>='A'&&str[i]<='Z')
			t = str[i] - 'A' + 10;
		else if(str[i]>='a'&&str[i]<='z')
			t = str[i] - 'a' + 36;
		else if(str[i] == '-')
			t = 62;
		else
			t = 63;
		int num = 0;
		while(t){
			if(t % 2 == 1) num++;
			t /= 2;
		}
		//cout<<' '<<num<<endl;
		ans = ans * (ll)pow(3,6-num) % MOD;
	}
	cout<<ans<<endl;
}


#include <set>
#include <map>
#include <queue>
#include <cmath>
#include <vector>
#include <cstdio>
#include <utility>
#include <cstring>
#include <iostream>
#include <algorithm>

const int mod = 1e9 + 7;

inline int toInt(char x)
{
    if('a' <= x && x <= 'z') return x - 'a' + 36;
    if('A' <= x && x <= 'Z') return x - 'A' + 10;
    if('0' <= x && x <= '9') return x - '0';
    if('-' == x) return 62;
    if('_' == x) return 63;
}

int main()
{
    std::string str;
    std::cin >> str;
    std::vector<int> vec, dp(70);
    for(int i = 0; i < str.size(); i ++) {
        vec.push_back(toInt(str[i]));
    }
    for(int i = 0; i <= 63; i ++) {
        for(int j = 0; j <= 63; j ++) dp[i & j] ++;
    }
    long long ans = 1ll;
    for(int i = 0; i < vec.size(); i ++) {
        ans *= dp[vec[i]];
        ans %= mod;
    }
    std::cout << ans << "\n";
}


#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#include<algorithm>
#include<queue>
using namespace std;
long long M=1e9+7,N=1;
char a[110000];
int how(int n)
{
	int i,t,count=0;
 	for(i=0;i<6;i++)
	{
		t=n%2;
		if(!t)
		count++;
		n/=2;
	}
	return count;
}

int main()
{

	scanf("%s",a);
	int i,l=strlen(a),n=0;
	for(i=0;i<l;i++)
	{
		char c=a[i];
		if(c>='0'&&c<='9')
		n+=how(c-'0');
		if(c>='A'&&c<='Z')
		n+=how(c-'A'+10);
		if(c>='a'&&c<='z')
		n+=how(c-'a'+36);
		if(c=='-')
		n+=how(62);
		if(c=='_')
		n+=how(63);
	}
	for(i=0;i<n;i++)
	{
		N*=3;
		N%=M;
	}
	printf("%I64d",N);
	return 0;
}


#include <cstdio>
#include <cstring>
#include <map>
using namespace std;
map <int, int> mp;
char str[100005];
int main()
{
    __int64 ans = 1, tmp;
    for(int i = 0; i < 64; i++)
        for(int j = 0; j < 64; j++)
            mp[i&j]++;
    scanf("%s", &str);
    for(int i = 0; i < strlen(str); i++)
    {
        if(str[i] == '-') tmp = 62;
        else if(str[i] == '_') tmp = 63;
        else if(str[i] >= 48 && str[i] <= 57) tmp = str[i] - 48;
        else if(str[i] >= 65 && str[i] <= 90) tmp = str[i] - 55;
        else tmp = str[i] - 61;
        ans = (ans * mp[tmp]) % 1000000007;
    }
    printf("%I64d\n", ans);
    return 0;
}


#include <cstdio>
#include <cstring>
#include <map>
using namespace std;
map <int, int> mp;
char str[100005];
int main()
{
    __int64 ans = 1;
    for(int i = 0; i < 64; i++)
        for(int j = 0; j < 64; j++)
            mp[i&j]++;
    scanf("%s", &str);
    for(int i = 0; i < strlen(str); i++)
    {
        if(str[i] == '-') str[i] = 62;
        else if(str[i] == '_') str[i] = 63;
        else if(str[i] >= 48 && str[i] <= 57) str[i] -= 48;
        else if(str[i] >= 65 && str[i] <= 90) str[i] -= 55;
        else str[i] -= 61;
        ans = ans * mp[str[i]] % 1000000007;
    }
    printf("%I64d\n", ans);
    return 0;
}


#include <cstdio>
#include <cstring>
#include <map>
using namespace std;
map <int, int> mp;
char str[100005];
int main()
{
    __int64 ans = 1;
    for(int i = 0; i < 64; i++)
        for(int j = 0; j < 64; j++)
            mp[i&j]++;
    scanf("%s", &str);
    for(int i = 0; i < strlen(str); i++)
    {
        if(str[i] == '-') str[i] = 62;
        else if(str[i] == '_') str[i] = 63;
        else if(str[i] >= 48 && str[i] <= 57) str[i] -= 48;
        else if(str[i] >= 65 && str[i] <= 90) str[i] -= 55;
        else str[i] -= 61;
        ans = (ans * mp[str[i]]) % 1000000007;
    }
    printf("%I64d\n", ans);
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define res(x,y) ((x%y)+y)%y
#define rep(x) for(int i=0;i<x;i++)
#define sqr(x) x*x
#define debug(args...) fprintf(stderr,args)

typedef pair<int, int> pii;
typedef long long ll;

#define M 1000000007

int f(char c)
{
	if (c>='0' && c<='9') return c-'0';
	if (c>='A' && c<='Z') return c-'A'+10;
	if (c>='a' && c<='z') return c-'a'+36;
	if (c == '-') return 62;
	return 63;
}

int main()
{
	int s[70];
	rep(64) s[i] = 0;
	rep(64) for(int j=0;j<64;j++) s[i&j]+=1;
	int resp = 1;
	char c = getchar();
	do
	{
		resp *= s[f(c)];
		resp %= M;
		c = getchar();
	} while(c != '\n');
	printf("%d\n", resp);
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define rep(n) for(int i=0, i<n;i++)
#define sqr(x) x*x
#define res(x,y) (x+x%y)%y
typedef long long ll;
typedef pair<int, int> pii;
long long unsigned bc = 1;
int q = 0;
#define M 1000000007
void toBin(int x)
{
	int c=1;
	int p=0;
	while(x)
	{
		p++;
		if (x%2 == 0) c*=2;
		x = x>>1;
	}
	for (int i=0;i<(6-p);i++)
	{
		c*=2;
	}
	bc *= c;
	if (c != 1) q++;
	cout << endl;
}
int getCode(int x)
{
	if (x >= '0' && x <= '9') return x-'0';
	if (x >= 'A' && x <= 'Z') return x-'A'+10;
	if (x >= 'a' && x <= 'z') return x-'a'+36;
	if (x == '-') return 62;
	else return 63;
}
int perm()
{

}
char s[100123];
int pas[100123][100123];
int main()
{
	scanf("%s", s);
	for (int i=0;i<strlen(s)+1;i++)
	{
		for (int j=0;j<i+1;j++)
		{
			if (j==0 || i == 0 || i == 1 || i == j)
			{
				pas[i][j] = 1;
			}
			else pas[i][j] = (pas[i-1][j-1]+pas[i-1][j])%(M);
		}
	}
	for (int i=0;i<strlen(s);i++)
	{
		toBin(getCode(s[i]));
	}
	long long unsigned sum = 0;
	for (int i=0;i<q;i++)
	{
		sum += pas[q][i];
		sum = sum%M;
	}
	cout << (int)pow(2,q)*(q+1)-(sum-1) << endl;
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define res(x,y) ((x%y)+y)%y
#define rep(x) for(int i=0;i<x;i++)
#define sqr(x) x*x
#define debug(args...) fprintf(stderr,args)

typedef pair<int, int> pii;
typedef long long ll;

#define M 1000000007

int f(char c)
{
	if (c>='0' && c<='9') return c-'0';
	if (c>='A' && c<='Z') return c-'A'+10;
	if (c>='a' && c<='z') return c-'a'+36;
	if (c == '-') return 62;
	return 63;
}

int main()
{
	ll s[70];
	rep(64) s[i] = 0;
	rep(64) for(int j=0;j<64;j++) s[i&j]+=1;
	ll resp = 1;
	char c = getchar();
	do
	{
		resp *= s[f(c)];
		resp %= M;
		c = getchar();
	} while(c != '\n');
	printf("%I64d\n", resp);
	return 0;
}


#include <bits/stdc++.h>
#define all(v) v.begin(),v.end()
#define fore(i,a,n) for(int i=a;i<n;i++)
#define rev(i,n) for(int i = n-1; i>= 0; i--)
#define pb push_back
#define mp make_pair
#define dprint(v) cerr << #v " = " << v << endl
#define endl '\n'
#define fill(m,v) memset(m,v,sizeof m)
using namespace std;

typedef long long ll;
typedef pair<int,int> ii;
const int N = 1505;
const ll mod = (ll) 1e9 + 7;

ll m[100005][70];
string s;
ll v[1000],n;
ll dp(int i, ll mask) {
	if(i == n)
		return 1LL;
	if(m[i][mask] != -1)
		return m[i][mask];

	ll r = 1;
	fore(j,0,64) {
		fore(k,0,64) {
			ll u = v[s[i]];
			if(u == (k & j)) {
				cout << j << " " << k << endl;
				r*= dp(i+1,j) + 1LL;
				if(i == 0)
					cout << "-------------------" << endl;
			}
		}
	}
	r = r % mod;
	return m[i][mask] = r;
}

int main() {
	cin >> s;
	ll h = 0;
	n = s.size();
	for(char i = '0'; i <= '9';i++)
		v[i] = h++;
	for(char i = 'A'; i <= 'Z';i++)
		v[i] = h++;
	for(char i = 'a'; i <= 'z';i++)
		v[i] = h++;
	v['-'] = h++;
	v['_'] = h++;

	/*ll r = 1LL;
	fore(i,0,n) {
		ll u = v[s[i]], cur = 0;
		fore(j,0,64)
			fore(k,0,64)
				if(u == (j & k))
					cur++;
		r *= cur;
		r = r % mod;
	}
	cout << r << endl;*/
	int r = 0;
	ll ans = 1;
	fore(i,0,s.size()) {
		ll u = v[s[i]];
		fore(i,0,6) {
			if((u & (1 << i)) == 0)
				r++;
		}
	}
	fore(i,0,r) {
		ans *= 3;
		ans = ans % mod;
	}
	cout << ans << endl;
}


#include <bits/stdc++.h>
#define all(v) v.begin(),v.end()
#define fore(i,a,n) for(int i=a;i<n;i++)
#define rev(i,n) for(int i = n-1; i>= 0; i--)
#define pb push_back
#define mp make_pair
#define dprint(v) cerr << #v " = " << v << endl
#define endl '\n'
#define fill(m,v) memset(m,v,sizeof m)
using namespace std;

typedef long long ll;
typedef pair<int,int> ii;
const int N = 1505;
const ll mod = (ll) 1e9 + 7;

ll m[100005][70];
string s;
ll v[1005],n;
ll dp(int i, ll mask) {
	if(i == n)
		return 1LL;
	if(m[i][mask] != -1)
		return m[i][mask];
	ll r = 1;
	fore(j,0,64) {
		fore(k,0,64) {
			ll u = v[s[i]];
			if(u == (k & j)) {
				cout << j << " " << k << endl;
				r*= dp(i+1,j) + 1LL;
				if(i == 0)
					cout << "-------------------" << endl;
			}
		}
	}
	r = r % mod;
	return m[i][mask] = r;
}

int main() {
	cin >> s;
	ll h = 0;
	n = s.size();
	for(char i = '0'; i <= '9';i++)
		v[i] = h++;
	for(char i = 'A'; i <= 'Z';i++)
		v[i] = h++;
	for(char i = 'a'; i <= 'z';i++)
		v[i] = h++;
	v['-'] = h++;
	v['_'] = h++;

	ll r = 1LL;
	fore(i,0,n) {
		ll u = v[s[i]], cur = 0;
		fore(j,0,64)
			fore(k,0,64)
				if(u == (j & k))
					cur++;
		r *= cur;
		r = r % mod;
	}
	cout << r << endl;
}


#include <bits/stdc++.h>
#define all(v) v.begin(),v.end()
#define fore(i,a,n) for(int i=a;i<n;i++)
#define rev(i,n) for(int i = n-1; i>= 0; i--)
#define pb push_back
#define mp make_pair
#define dprint(v) cerr << #v " = " << v << endl
#define endl '\n'
#define fill(m,v) memset(m,v,sizeof m)
using namespace std;

typedef long long ll;
typedef pair<int,int> ii;
const int N = 1505;
const ll mod = (ll) 1e9 + 7;

ll m[100005][70];
string s;
ll v[1000],n;
ll dp(int i, ll mask) {
	if(i == n)
		return 1LL;
	if(m[i][mask] != -1)
		return m[i][mask];

	ll r = 1;
	fore(j,0,64) {
		fore(k,0,64) {
			ll u = v[s[i]];
			if(u == (k & j)) {
				cout << j << " " << k << endl;
				r*= dp(i+1,j) + 1LL;
				if(i == 0)
					cout << "-------------------" << endl;
			}
		}
	}
	r = r % mod;
	return m[i][mask] = r;
}

int main() {
	cin >> s;
	ll h = 0;
	n = s.size();
	for(char i = '0'; i <= '9';i++)
		v[i] = h++;
	for(char i = 'A'; i <= 'Z';i++)
		v[i] = h++;
	for(char i = 'a'; i <= 'z';i++)
		v[i] = h++;
	v['-'] = h++;
	v['_'] = h++;

	ll r = 1LL;
	fore(i,0,n) {
		ll u = v[s[i]], cur = 0;
		fore(j,0,64)
			fore(k,0,64)
				if(u == (j & k))
					cur++;
		r *= cur;
		r = r % mod;
	}
	cout << r << endl;
}


#include <bits/stdc++.h>
#define all(v) v.begin(),v.end()
#define fore(i,a,n) for(int i=a;i<n;i++)
#define rev(i,n) for(int i = n-1; i>= 0; i--)
#define pb push_back
#define mp make_pair
#define dprint(v) cerr << #v " = " << v << endl
#define endl '\n'
#define fill(m,v) memset(m,v,sizeof m)
using namespace std;

typedef long long ll;
typedef pair<int,int> ii;
const int N = 1505;
const ll mod = (ll) 1e9 + 7;

ll m[100005][70];
string s;
ll v[1000],n;
ll dp(int i, ll mask) {
	if(i == n)
		return 1LL;
	if(m[i][mask] != -1)
		return m[i][mask];

	ll r = 1;
	fore(j,0,64) {
		fore(k,0,64) {
			ll u = v[s[i]];
			if(u == (k & j)) {
				cout << j << " " << k << endl;
				r*= dp(i+1,j) + 1LL;
				if(i == 0)
					cout << "-------------------" << endl;
			}
		}
	}
	r = r % mod;
	return m[i][mask] = r;
}

int main() {
	cin >> s;
	ll h = 0;
	n = s.size();
	for(char i = '0'; i <= '9';i++)
		v[i] = h++;
	for(char i = 'A'; i <= 'Z';i++)
		v[i] = h++;
	for(char i = 'a'; i <= 'z';i++)
		v[i] = h++;
	v['-'] = h++;
	v['_'] = h++;

	/*ll r = 1LL;
	fore(i,0,n) {
		ll u = v[s[i]], cur = 0;
		fore(j,0,64)
			fore(k,0,64)
				if(u == (j & k))
					cur++;
		r *= cur;
		r = r % mod;
	}
	cout << r << endl;*/
	int r = 0;
	ll ans = 1;
	fore(i,0,s.size()) {
		ll u = v[s[i]];
		fore(i,0,6) {
			if((u & (1 << i)) == 0)
				r++;
		}
	}
	fore(i,0,r) {
		ans *= 3;
		if(ans >= mod)
			ans -= mod;
	}
	cout << ans << endl;
}


#include <bits/stdc++.h>
#define all(v) v.begin(),v.end()
#define fore(i,a,n) for(int i=a;i<n;i++)
#define rev(i,n) for(int i = n-1; i>= 0; i--)
#define pb push_back
#define mp make_pair
#define dprint(v) cerr << #v " = " << v << endl
#define endl '\n'
#define fill(m,v) memset(m,v,sizeof m)
using namespace std;

typedef long long ll;
typedef pair<int,int> ii;
const int N = 1505;
const ll mod = (ll) 1e9 + 7;

ll m[100005][70];
string s;
ll v[1000],n;
ll dp(int i, ll mask) {
	if(i == n)
		return 1LL;
	if(m[i][mask] != -1)
		return m[i][mask];

	ll r = 1;
	fore(j,0,64) {
		fore(k,0,64) {
			ll u = v[s[i]];
			if(u == (k & j)) {
				cout << j << " " << k << endl;
				r*= dp(i+1,j) + 1LL;
				if(i == 0)
					cout << "-------------------" << endl;
			}
		}
	}
	r = r % mod;
	return m[i][mask] = r;
}

int main() {
	cin >> s;
	ll h = 0;
	n = s.size();
	for(char i = '0'; i <= '9';i++)
		v[i] = h++;
	for(char i = 'A'; i <= 'Z';i++)
		v[i] = h++;
	for(char i = 'a'; i <= 'z';i++)
		v[i] = h++;
	v['-'] = h++;
	v['_'] = h++;

	/*ll r = 1LL;
	fore(i,0,n) {
		ll u = v[s[i]], cur = 0;
		fore(j,0,64)
			fore(k,0,64)
				if(u == (j & k))
					cur++;
		r *= cur;
		r = r % mod;
	}
	cout << r << endl;*/
	int r = 0;
	ll ans = 1;
	fore(i,0,s.size()) {
		ll u = v[s[i]];
		fore(i,0,6) {
			if((u & (1 << i)) == 0)
				r++;
		}
	}
	fore(i,0,r) {
		ans *= 3;
		while(ans >= mod)
			ans -= mod;
	}
	cout << ans << endl;
}


#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#include<algorithm>
#include<queue>
using namespace std;
long long M=1e9+7;
int chars(char c)
{
		if(c>='0'&&c<='9')
		return(c-'0');
		if(c>='A'&&c<='Z')
		return(c-'A'+10);
		if(c>='a'&&c<='z')
		return(c-'a'+36);
		if(c=='-')
		return(62);
		if(c=='_')
		return(63);
}
int main()
{
	char a[110000],num[100];
	memset(num,0,sizeof(num));
	scanf("%s",a);
	int i,j,l=strlen(a);
	long long ans=1;
	for(i=0;i<64;i++)
	for(j=0;j<64;j++)
	num[i&j]++;

	for(i=0;i<l;i++)
	{
		ans=(ans*num[chars(a[i])])%M;
	}
	printf("%I64d",ans);
	return 0;
}

/*#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#include<algorithm>
#include<queue>
using namespace std;
long long M=1e9+7,N=1;
int how(int n)
{
	int i,t,count=0;
 	for(i=0;i<6;i++)
	{
		t=n%2;
		if(!t)
		count++;
		n/=2;
	}
	return count;
}

int main()
{
	char a[10000];
	scanf("%s",a);
	int i,l=strlen(a),n=0;
	for(i=0;i<l;i++)
	{
		char c=a[i];
		if(c>='0'&&c<='9')
		n+=how(c-'0');
		if(c>='A'&&c<='Z')
		n+=how(c-'A'+10);
		if(c>='a'&&c<='z')
		n+=how(c-'a'+36);
		if(c=='-')
		n+=how(62);
		if(c=='_')
		n+=how(63);
	}
	for(i=0;i<n;i++)
	{
		N*=3;
		N%=M;
	}
	printf("%I64d",N);
	return 0;
}*/


#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#include<algorithm>
#include<queue>
using namespace std;
long long M=1e9+7,num[100];
int chars(char c)
{
		if(c>='0'&&c<='9')
		return(c-'0');
		if(c>='A'&&c<='Z')
		return(c-'A'+10);
		if(c>='a'&&c<='z')
		return(c-'a'+36);
		if(c=='-')
		return(62);
		if(c=='_')
		return(63);
}
int main()
{
	char a[110000];
	memset(num,0,sizeof(num));
	scanf("%s",a);
	//int i,j,l=strlen(a);
	long long i,j,ans=1,l=strlen(a);
	for(i=0;i<64;i++)
	for(j=0;j<64;j++)
	num[i&j]++;

	for(i=0;i<l;i++)
	{
		ans=(ans*num[chars(a[i])])%M;
	}
	printf("%I64d",ans);
	return 0;
}

/*#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#include<algorithm>
#include<queue>
using namespace std;
long long M=1e9+7,N=1;
int how(int n)
{
	int i,t,count=0;
 	for(i=0;i<6;i++)
	{
		t=n%2;
		if(!t)
		count++;
		n/=2;
	}
	return count;
}

int main()
{
	char a[10000];
	scanf("%s",a);
	int i,l=strlen(a),n=0;
	for(i=0;i<l;i++)
	{
		char c=a[i];
		if(c>='0'&&c<='9')
		n+=how(c-'0');
		if(c>='A'&&c<='Z')
		n+=how(c-'A'+10);
		if(c>='a'&&c<='z')
		n+=how(c-'a'+36);
		if(c=='-')
		n+=how(62);
		if(c=='_')
		n+=how(63);
	}
	for(i=0;i<n;i++)
	{
		N*=3;
		N%=M;
	}
	printf("%I64d",N);
	return 0;
}*/


#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <string.h>
using namespace std;
const int MAX = 1e5 + 5;

int powMod(int a, int pow, int MOD){
	long long ans = 1LL;
	while (pow){
		if (pow % 2) ans*= a, ans %= MOD;
		a*= a;
		a %= MOD;
		pow/=2;
	}
	return (int) ans;
}

int main(){
	int n1[64];
	for(int i = 0; i < 64; ++i){
		n1[i] = __builtin_popcount(i);
	}

	char s[MAX];
	gets(s);
	int len = strlen(s);
	int len1 = len;
	char c;
	int a, n_one = 0, nzero;
	while (len > 0){
		c = s[--len];
		if (c >= '0' && c <= '9') a = c - '0';
		if (c >= 'A' && c <= 'Z') a = c - 55;
		if (c >= 'a' && c <= 'z') a = c - 61;
		if (c == '-') a = 62;
		if (c == '_') a = 63;
		n_one += n1[a];
	}

	nzero = (len1)*6 - n_one;
	printf("%d", powMod(3, nzero, 1e9 + 7));
}


#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <string.h>
using namespace std;
const int MAX = 1e5 + 5;

int powMod(int a, int pow, int MOD){
	long long ans = 1LL;
	while (pow){
		if (pow % 2) ans*= a, ans %= MOD;
		a*= a;
		a %= MOD;
		pow/=2;
	}
	return (int) ans;
}

int main(){
	int n1[64];
	for(int i = 0; i < 64; ++i){
		n1[i] = __builtin_popcount(i);
	}

	char s[MAX];
	gets(s);
	int len = strlen(s);
	int len1 = len;
	char c;
	int a, n_one = 0, nzero;
	while (len > 0){
		c = s[--len];
		if (c >= '0' && c <= '9') a = c - '0';
		if (c >= 'A' && c <= 'Z') a = c - 55;
		if (c >= 'a' && c <= 'z') a = c - 61;
		if (c == '-') a = 62;
		if (c == '_') a = 63;
		n_one += n1[a];
		printf("n_one = %d\n", n_one);
	}

	nzero = (len1)*6 - n_one;
	printf("%d", powMod(3, nzero, 1e9 + 7));
}


#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <string.h>
using namespace std;
const int MAX = 1e5 + 5;

long long powMod(int a, int pow, int MOD){
	long long base = (long long) a;
	long long ans = 1LL;
	while (pow){
		if (pow % 2) ans*= base, ans %= MOD;
		base*= base;
		base %= MOD;
		pow/=2;
	}
	return ans;
}

int main(){
	int n1[64];
	for(int i = 0; i < 64; ++i){
		n1[i] = __builtin_popcount(i);
	}

	char s[MAX];
	gets(s);
	int len = strlen(s);
	int len1 = len;
	char c;
	int a, n_one = 0, nzero;
	while (len > 0){
		c = s[--len];
		if (c >= '0' && c <= '9') a = c - '0';
		if (c >= 'A' && c <= 'Z') a = c - 55;
		if (c >= 'a' && c <= 'z') a = c - 61;
		if (c == '-') a = 62;
		if (c == '_') a = 63;
		n_one += n1[a];
	}

	nzero = (len1)*6 - n_one;
	printf("%I64d", powMod(3, nzero, 1e9 + 7));
}


#include <iostream>
#include <cstring>
#include <algorithm>

using namespace std;

int main(void)
{
  ios::sync_with_stdio(false);
  cin.tie(0);

  char input[100010];
  int data[100010];
  cin >> input;
  int len = strlen(input);
  for (int i = 0; i < len; ++i) {
    if (input[i] >= '0' && input[i] <= '9') {
      data[i] = input[i] - '0';
    }
    else if (input[i] >= 'A' && input[i] <= 'Z') {
      data[i] = input[i] - 'A' + 10;
    }
    else if (input[i] >= 'a' && input[i] <= 'z') {
      data[i] = input[i] - 'a' + 36;
    }
    else if (input[i] == '-')
      data[i] = 62;
    else if (input[i] == '_')
      data[i] = 63;

  }
  int acc = 0;

  for (int i = 0; i < len; ++i) {
    for (int j = 0; j < 6; ++j) {
      if (data[i] % 2 == 0) acc++;
      data[i] = data[i] >> 1;
    }
  }

  long long int ans = 1;

  while (acc) {
    while (ans < 1000000007 && acc) {
      ans *= 3;
      acc--;
    }
    if (ans > 1000000007);
      ans %= 1000000007;
  }

  cout << ans << endl;

  return 0;
}


#include <iostream>
#include <cstring>
#include <algorithm>

using namespace std;

int main(void)
{
  ios::sync_with_stdio(false);
  cin.tie(0);

  char input[100];
  int data[100];
  cin >> input;
  int len = strlen(input);
  for (int i = 0; i < len; ++i) {
    if (input[i] >= '0' && input[i] <= '9') {
      data[i] = input[i] - '0';
    }
    else if (input[i] >= 'A' && input[i] <= 'Z') {
      data[i] = input[i] - 'A' + 10;
    }
    else if (input[i] >= 'a' && input[i] <= 'z') {
      data[i] = input[i] - 'a' + 36;
    }
    else if (input[i] == '-')
      data[i] = 62;
    else if (input[i] == '_')
      data[i] = 63;

  }
  int acc = 0;

  for (int i = 0; i < len; ++i) {
    for (int j = 0; j < 6; ++j) {
      if (data[i] % 2 == 0) acc++;
      data[i] = data[i] >> 1;
    }
  }

  long long int ans = 1;

  while (acc) {
    while (ans < 1000000007 && acc) {
      ans *= 3;
      acc--;
    }
    if (ans > 1000000007);
      ans %= 1000000007;
  }

  cout << ans << endl;

  return 0;
}


#include <iostream>
#include <cstring>
#include <algorithm>

using namespace std;

int main(void)
{
  ios::sync_with_stdio(false);
  cin.tie(0);

  char input[100];
  int data[100];
  cin >> input;
  int len = strlen(input);
  for (int i = 0; i < len; ++i) {
    if (input[i] >= '0' && input[i] <= '9') {
      data[i] = input[i] - '0';
    }
    else if (input[i] >= 'A' && input[i] <= 'Z') {
      data[i] = input[i] - 'A' + 10;
    }
    else if (input[i] >= 'a' && input[i] <= 'z') {
      data[i] = input[i] - 'a' + 36;
    }
    else if (input[i] == '-')
      data[i] = 62;
    else if (input[i] == '_')
      data[i] = 63;

  }
  //cout << input[0] << " "<< data[0] << " " << len << endl;
  int acc = 0;

  for (int i = 0; i < len; ++i) {
    for (int j = 0; j < 6; ++j) {
      if (data[i] % 2 == 0) acc++;
      data[i] = data[i] >> 1;
      //cout << data[i] << " " << acc << endl;
    }
  }

  long long int ans = 1;

  for (int i = 0; i < acc; ++i) {
    ans *= 3;
    ans %= 1000000007;

  }

  cout << ans << endl;

  return 0;
}


#include<iostream>
#include<string.h>
#include<stdio.h>
#include<cmath>
using namespace std;
long long mod=1000000007;
char s[100001];
int get(char c)
{
    if(c<='9'&&c>='0')return c-'0';
    if(c<='z'&&c>='a')return 36+c-'a';
    if(c<='Z'&&c>='A')return 10+c-'A';
    if(c=='-')return 62;
    if(c=='_')return 63;

}
int main()
{

    scanf("%s",s);
    int l=strlen(s);
    int i,j;
    long long ans=1;
    for(i=0;i<l;i++)
    {
        int t=get(s[i]);
        for(j=0;j<6;j++)
        {
            if((t&(1<<j))==0)ans=ans*3%mod;
        }
    }

    cout<<ans<<endl;
    return 0;

}


#include<iostream>
#include<stdio.h>
using namespace std;
int f[1000010];
int main()
{
    int n;
    cin>>n;
    int i;
    f[1]=f[2]=1;
    for(i=3;i<=1000000;i++)
        f[i]=(f[i-1]+f[i-2])%10007;
    cout<<f[n]<<endl;
    return 0;
}


#include <iostream>
#include <cstdio>
#include <cstring>
#define LL long long
#define MOD(num) num = num%1000000007
using namespace std;

LL change(char c)
{
    if(c == '-')
        return 62;
    if(c == '_')
        return 63;
    if('0'<= c&&c <='9')
        return c-'0';
    if('A'<= c&&c <='Z')
        return (c-'A')+10;
    if('a'<= c&&c <='z')
        return (c-'a' + 36);

    return 63;
}
LL getZero(LL a)
{
    LL ret = 0;
    for(LL i =0; i< 6; i++)
    {
        if((a&1) != 1)
        {
            ret++;
        }
        a = a>>1;
    }
    return ret;
}
LL pow(LL a, LL p)
{
    LL ans = 1;
    LL tmp = a;
    while(p != 0)
    {
        if(p&1)
        {
            ans *= tmp;
            MOD(ans);
        }
        tmp *= tmp;
        p = p>>1;
        MOD(tmp);
    }
    return ans;
}

int main()
{
    char c;
    LL num = 0;
    while(true)
    {
        c = getchar();
        if(c == '\n')
            break;
        num += getZero(change(c));
    }
    printf("%I64d",pow(3, num));
    return 0;
}


#include <iostream>
#include <cstdio>
#include <cstring>
#include <set>
#include <map>
using namespace std;

char a[200000];
int n[200000];
int al;
char b[200000];
int bl;

int pos[200000];
int num;

int main()
{
    int i,j;
    num = 0;

    scanf("%s", a);
    al = strlen(a);
    scanf("%s", b);
    bl = strlen(b);
    for(i = 0; i < al; i++)
    {
        scanf("%d", &n[al-1-i]);//����
    }
    for(i = 0; i<al ; i++)
    {
        if(num == bl)
            break;
        for(j =0; j < bl; j++)
        {

            if(a[j] == )
        }
    }
    printf("%d\n", al - i);
    return 0;
}
/*
ababcba
abb
5 3 4 1 7 6 2
*/


#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mset(m,v) memset(m,v,sizeof(m))
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pi 3.1415926535897932384
#define mod 1000000007
#define MAXM 1000000001

map<char,int> m;
int a[156]={0};

void humtum()
{
    for(int i=0;i<=9;i++)
    {
        m[i+'0']=i;
    }
    for(int i=0;i<26;i++)
    {
        m[i+'A']=i+10;
        m[i+'a']=i+36;
    }
    m['-']=62;
    m['_']=63;
}

void jhaat()
{
    for(int i=0;i<=63;i++)
    {
        for(int j=0;j<=63;j++)
        {
            a[i&j]++;
        }
    }
}

void solve()
{
    string s;
    int i,j,k;
    cin>>s;

    ll ans=1;

    for(int ii=0;ii<s.size();ii++)
    {
        int x = m[s[ii]];
        // cout<<x<<endl;
        ll cnt=a[x];
        ans = ans*cnt;
        if(ans>=mod)    ans%=mod;
    }
    cout<<ans<<endl;
}

int main()
{
    jhaat();
    humtum();
    solve();
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mset(m,v) memset(m,v,sizeof(m))
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pi 3.1415926535897932384
#define mod 1000000007
#define MAXM 1000000001

map<char,int> m;

void humtum()
{
    for(int i=0;i<=9;i++)
    {
        m[i+'0']=i;
    }
    for(int i=0;i<26;i++)
    {
        m[i+'A']=i+10;
        m[i+'a']=i+36;
    }
    m['-']=62;
    m['_']=63;
}

void solve()
{
    string s;
    int i,j,k;
    cin>>s;

    ll ans=1;

    for(int ii=0;ii<s.size();ii++)
    {
        ll cnt=0;
        int x = m[s[ii]];
        // cout<<x<<endl;
        for(i=0;i<=63;i++)
        {
            for(j=0;j<=63;j++)
            {
                if((i&j)==x)
                    cnt++;
                if(cnt>=mod)
                    cnt%=mod;
            }
        }
        ans = ans*cnt;
        if(ans>=mod)    ans%=mod;
    }
    cout<<ans<<endl;
}

int main()
{
    humtum();
    solve();
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mset(m,v) memset(m,v,sizeof(m))
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pi 3.1415926535897932384
#define mod 1000000007
#define MAXM 1000000001

map<char,int> m;
int a[64]={0};

void humtum()
{
    for(int i=0;i<=9;i++)
    {
        m[i+'0']=i;
    }
    for(int i=0;i<26;i++)
    {
        m[i+'A']=i+10;
        m[i+'a']=i+36;
    }
    m['-']=62;
    m['_']=63;
}

void jhaat()
{
    for(int i=0;i<=63;i++)
    {
        for(int j=0;j<=63;j++)
        {
            a[i&j]++;
        }
    }
}

void solve()
{
    string s;
    int i,j,k;
    cin>>s;

    ll ans=1;

    for(int ii=0;ii<s.size();ii++)
    {
        int x = m[s[ii]];
        // cout<<x<<endl;
        ll cnt=a[x];
        ans = ans*cnt;
        if(ans>=mod)    ans%=mod;
    }
    cout<<ans<<endl;
}

int main()
{
    jhaat();
    humtum();
    solve();
    return 0;
}


#include <bits/stdc++.h>
#define pii pair<int,int>
#define ll long long
#define pb push_back
#define mp make_pair
#define mod 1000000007
using namespace std;

ll gcd(ll a, ll b){
    if(b==0)    return a;
    return gcd(b, a%b);
}

ll lcm(ll a, ll b){
    return (a/gcd(a,b))*b;
}

int value(char c)
{
	if(c<='9')
		return c-'0';
	if(c>='A' && c<='Z')
		return c-'A'+10;
	if(c>='a' && c<='z')
		return c-'a'+36;
	if(c=='-')
		return 62;
	return 63;
}

int set_bits(int n)
{
	int count=0;
	while(n)
	{
		count += n & 1;
	    n >>= 1;
	}
	return count;
}
long long pow(int a, int b, int MOD)
{
    long long x=1,y=a;
    while(b > 0)
    {
        if(b%2 == 1)
        {
            x=(x*y);
            if(x>MOD) x%=MOD;
        }
        y = (y*y);
        if(y>MOD) y%=MOD;
        b /= 2;
    }
    return x;
}

long long InverseEuler(int n, int MOD)
{
    return pow(n,MOD-2,MOD);
}

long long C(int n, int r, int MOD)
{
    vector<long long> f(n + 1,1);
    for (int i=2; i<=n;i++)
        f[i]= (f[i-1]*i) % MOD;
    return (f[n]*((InverseEuler(f[r], MOD) * InverseEuler(f[n-r], MOD)) % MOD)) % MOD;
}

int main()
{
	ll i,j,h,k,m,t,ans,n,p,flag,q,sum;
	string s;
	getline(cin,s);
	ans=0;

	for(i=0;i<s.length();i++)
	{
		k=value(s[i]);
		j=6-set_bits(k);
		ans+=j;
	}
	j=2;
	t=ans;
	k=1;
	for(i=1;i<=ans;i++)
	{
		k+=j*t;
		t=C(ans,i+1,mod);
		j*=2;
		j=j%mod;
		k=k%mod;
	}

	cout<<k<<endl;

	return 0;
}


#include <bits/stdc++.h>
#define pii pair<int,int>
#define ll long long
#define pb push_back
#define mp make_pair
#define mod 1000000007
using namespace std;

ll gcd(ll a, ll b){
    if(b==0)    return a;
    return gcd(b, a%b);
}

ll lcm(ll a, ll b){
    return (a/gcd(a,b))*b;
}

int value(char c)
{
	if(c<='9')
		return c-'0';
	if(c>='A' && c<='Z')
		return c-'A'+10;
	if(c>='a' && c<='z')
		return c-'a'+36;
	if(c=='-')
		return 62;
	return 63;
}

int set_bits(int n)
{
	int count=0;
	while(n)
	{
		count += n & 1;
	    n >>= 1;
	}
	return count;
}
long long pow(int a, int b, int MOD)
{
    long long x=1,y=a;
    while(b > 0)
    {
        if(b%2 == 1)
        {
            x=(x*y);
            if(x>MOD) x%=MOD;
        }
        y = (y*y);
        if(y>MOD) y%=MOD;
        b /= 2;
    }
    return x;
}

long long InverseEuler(int n, int MOD)
{
    return pow(n,MOD-2,MOD);
}

vector<long long> f(600001,1);

long long C(int n, int r, int MOD)
{

    return (f[n]*((InverseEuler(f[r], MOD) * InverseEuler(f[n-r], MOD)) % MOD)) % MOD;
}

int main()
{
	ll i,j,h,k,m,t,ans,n,p,flag,q,sum;
	string s;
	cin>>s;
	ans=0;

	for (i=2; i<=600000;i++)
        f[i]= (f[i-1]*i) % mod;

	for(i=0;i<s.length();i++)
	{
		k=value(s[i]);
		j=6-set_bits(k);
		ans+=j;
	}
	j=2;
	t=ans;
	k=1;
	for(i=1;i<=ans;i++)
	{
		k+=j*t;
		t=C(ans,i+1,mod);
		j*=2;
		j=j%mod;
		k=k%mod;
	}

	cout<<k<<endl;

	return 0;
}


#include <bits/stdc++.h>
#define pii pair<int,int>
#define ll long long
#define pb push_back
#define mp make_pair
#define mod 1000000007
using namespace std;

ll gcd(ll a, ll b){
    if(b==0)    return a;
    return gcd(b, a%b);
}

ll lcm(ll a, ll b){
    return (a/gcd(a,b))*b;
}

int value(char c)
{
	if(c<='9' && c>='0')
		return c-'0';
	if(c>='A' && c<='Z')
		return c-'A'+10;
	if(c>='a' && c<='z')
		return c-'a'+36;
	if(c=='_')
		return 63;
	return 62;
}

int set_bits(int n)
{
	int count=0;
	while(n)
	{
		count += n & 1;
	    n >>= 1;
	}
	return count;
}
long long pow(int a, int b, int MOD)
{
    long long x=1,y=a;
    while(b > 0)
    {
        if(b%2 == 1)
        {
            x=(x*y);
            if(x>MOD) x%=MOD;
        }
        y = (y*y);
        if(y>MOD) y%=MOD;
        b /= 2;
    }
    return x;
}

long long InverseEuler(int n, int MOD)
{
    return pow(n,MOD-2,MOD);
}

vector<long long> f(600001,1);

long long C(int n, int r, int MOD)
{

    return (f[n]*((InverseEuler(f[r], MOD) * InverseEuler(f[n-r], MOD)) % MOD)) % MOD;
}

int main()
{
	ll i,j,h,k,m,t,ans,n,p,flag,q,sum;
	string s;
	cin>>s;
	ans=0;

	for (i=2; i<=600000;i++)
        f[i]= (f[i-1]*i) % mod;

	for(i=0;i<s.length();i++)
	{
		k=value(s[i]);
		j=6-set_bits(k);
		ans+=j;
	}
	j=2;
	t=ans;
	k=1;
	for(i=1;i<=ans;i++)
	{
		k+=j*t;
		t=C(ans,i+1,mod);
		j*=2;
		j=j%mod;
		k=k%mod;
	}

	cout<<k<<endl;

	return 0;
}


#include <bits/stdc++.h>
#define pii pair<int,int>
#define ll long long
#define pb push_back
#define mp make_pair
#define mod 1000000007
using namespace std;

ll gcd(ll a, ll b){
    if(b==0)    return a;
    return gcd(b, a%b);
}

ll lcm(ll a, ll b){
    return (a/gcd(a,b))*b;
}

int value(char c)
{
	if(c<='9')
		return c-'0';
	if(c>='A' && c<='Z')
		return c-'A'+10;
	if(c>='a' && c<='z')
		return c-'a'+36;
	if(c=='-')
		return 62;
	return 63;
}

int set_bits(int n)
{
	int count=0;
	while(n)
	{
		count += n & 1;
	    n >>= 1;
	}
	return count;
}

int main()
{
	ll i,j,h,k,m,t,ans,n,p,flag,q,sum;
	string s;
	cin>>s;
	ans=0;

	for(i=0;i<s.length();i++)
	{
		k=value(s[i]);
		j=6-set_bits(k);
		ans+=j;
	}
	j=2;
	t=ans;
	k=1;
	//cout<<ans<<endl;
	for(i=1;i<=ans;i++)
	{
		k+=j*t;
		t=t*(ans-i);
		t=t/(i+1);
		j*=2;
		j=j%mod;
		t=t%mod;
		k=k%mod;
		//cout<<k<<" "<<j<<" "<<t<<endl;
	}

	cout<<k<<endl;

	return 0;
}


#include <iostream>
#include <vector>
#include <set>
#include <cstdlib>

using namespace std;

typedef long long ll;
#define prim 1000000007LL
int main()
{
    ios_base::sync_with_stdio(0);
    string s;
    ll arr[34678];
    cin>>s;
    ll ans=1;
    for(int i=0;i<s.length();++i){
        if(s[i]=='-')
            arr[i]=62LL;
        else if(s[i]<='9')
            arr[i]=(ll)s[i]-'9';
        else if(s[i]<='Z')
            arr[i]=(ll)(s[i]-'A')+10;
            else if(s[i]=='_')
            arr[i]=63LL;
        else if(s[i]<='z')
            arr[i]=(ll)((s[i]-'a')+36);

        ll cnt=1;
        for(ll j=0;j<6;j++){

            if(!(arr[i]&1LL)){
                cnt*=3LL;
                cnt%=prim;
            }
            arr[i]>>=1;
        }
        ans*=cnt;
        ans%=prim;

    }
    cout<<ans<<endl;
    return 0;
}


#include <iostream>
#include <vector>
#include <set>
#include <cstdlib>

using namespace std;

typedef long long ll;
ll prim = 1000000007LL;
int main()
{
    ios_base::sync_with_stdio(0);
    string s;
    ll arr[34678];
    cin>>s;
    ll ans=1;
    for(ll i=0;i<s.length();++i){
        if(s[i]=='-')
            arr[i]=62LL;
        else if(s[i]<='9')
            arr[i]=(ll)s[i]-'9';
        else if(s[i]<='Z')
            arr[i]=(ll)(s[i]-'A')+10;
            else if(s[i]=='_')
            arr[i]=63LL;
        else if(s[i]<='z')
            arr[i]=(ll)((s[i]-'a')+36);

        ll cnt=1;
        for(ll j=0;j<6;j++){

            if(!(arr[i]&1LL)){
                cnt*=3LL;
                cnt%=prim;
            }
            arr[i]>>=1;
        }
        ans*=cnt;
        ans%=prim;

    }
    cout<<ans<<endl;
    return 0;
}


#include <iostream>
#include <vector>
#include <set>
#include <cstdlib>

using namespace std;

typedef long long ll;
ll prim = 1000000007LL
int main()
{
    ios_base::sync_with_stdio(0);
    string s;
    ll arr[34678];
    cin>>s;
    ll ans=1;
    for(ll i=0;i<s.length();++i){
        if(s[i]=='-')
            arr[i]=62LL;
        else if(s[i]<='9')
            arr[i]=(ll)s[i]-'9';
        else if(s[i]<='Z')
            arr[i]=(ll)(s[i]-'A')+10;
            else if(s[i]=='_')
            arr[i]=63LL;
        else if(s[i]<='z')
            arr[i]=(ll)((s[i]-'a')+36);

        ll cnt=1;
        for(ll j=0;j<6;j++){

            if(!(arr[i]&1LL)){
                cnt*=3LL;
                cnt%=prim;
            }
            arr[i]>>=1;
        }
        ans*=cnt;
        ans%=prim;

    }
    cout<<ans<<endl;
    return 0;
}


#include <iostream>
#include <vector>
#include <set>
#include <cstdlib>

using namespace std;

typedef long long ll;
ll prim = 1000000007LL;
int main()
{
    ios_base::sync_with_stdio(0);
    string s;
    ll arr[34678];
    cin>>s;
    ll ans=1;
    for(ll i=0;i<s.length();++i){
        if(s[i]=='-')
            arr[i]=62LL;
        else if(s[i]<='9')
            arr[i]=(ll)s[i]-'0';
        else if(s[i]<='Z')
            arr[i]=(ll)(s[i]-'A')+10;
            else if(s[i]=='_')
            arr[i]=63LL;
        else if(s[i]<='z')
            arr[i]=(ll)((s[i]-'a')+36);

        ll cnt=1;
        for(ll j=0;j<6;j++){

            if(!(arr[i]&1LL)){
                cnt*=3LL;
                cnt%=prim;
            }
            arr[i]>>=1;
        }
        ans*=cnt;
        ans%=prim;

    }
    cout<<ans<<endl;
    return 0;
}


#include <iostream>
#include <vector>
#include <set>
#include <cstdlib>

using namespace std;

typedef long long ll;
ll prim = 1000000007LL;
int main()
{
    ios_base::sync_with_stdio(0);
    string s;
    ll arr[345678];
    cin>>s;
    ll ans=1;
    for(ll i=0;i<s.length();++i){
        if(s[i]=='-')
            arr[i]=62LL;
        else if(s[i]<='9')
            arr[i]=(ll)s[i]-'0';
        else if(s[i]<='Z')
            arr[i]=(ll)(s[i]-'A')+10;
            else if(s[i]=='_')
            arr[i]=63LL;
        else if(s[i]<='z')
            arr[i]=(ll)((s[i]-'a')+36);

        ll cnt=1;
        for(ll j=0;j<6;j++){

            if(!(arr[i]&1LL)){
                cnt*=3LL;
                cnt%=prim;
            }
            arr[i]>>=1;
        }
        ans*=cnt;
        ans%=prim;

    }
    cout<<ans<<endl;
    return 0;
}


#include <bits/stdc++.h>
#define ultrax_007 ios_base::sync_with_stdio(false);cin.tie(NULL)
#define ll long long
#define pb push_back
#define pr pair<int, int>
#define mp make_pair
using namespace std;
int covert(char c){
    int x=c;
    if(x>=48 && x<=57){
        return x-48;
    }
    if(x>=65 && x<=90){
        return x-65+10;
    }
    if(x>=97 && x<=122){
        return x-97+36;
    }
    if(x=='-'){
        return 62;
    }
    if(x=='_'){
        return 63;
    }

}

int main(){
    ultrax_007;
    int a[64][6];
    for(int i=0;i<64;i++){
        for(int j=0;j<6;j++){
            a[i][j]=0;
        }
    }
    for(int i=1;i<64;i++){
        int note=i;
        int j=0;
        while(note!=0){
            a[i][j]=note%2;
            note/=2;
            j++;
        }
    }
    string s;
    cin>>s;
    int count=0;
    for(int i=0;i<s.length();i++){
        int k=covert(s[i]);
       // cout<<k<<endl;

        for(int j=0;j<6;j++){
            if(a[k][j]==0){
                count++;
            }
        }

    }
   // cout<<count<<endl;
    ll int ans=1;
    for(int i=0;i<count;i++){
        ans=(3*ans)%1000000007;
    }

    cout<<ans   ;
    //for(int i=0;i<6;i++){
    //    cout<<a[61][i]<<" ";
    //}

    return 0;
}


#include <bits/stdc++.h>
#define ultrax_007 ios_base::sync_with_stdio(false);cin.tie(NULL)
#define ll long long
#define pb push_back
#define pr pair<int, int>
#define mp make_pair
using namespace std;
int covert(char c){
    int x=c;
    if(x>=48 && x<=57){
        return x-48;
    }
    if(x>=65 && x<=90){
        return x-65+10;
    }
    if(x>=97 && x<=122){
        return x-97+36;
    }
    if(x=='-'){
        return 62;
    }
    if(x=='_'){
        return 63;
    }

}

int main(){
    ultrax_007;
    int a[64][6];
    for(int i=0;i<64;i++){
        for(int j=0;j<6;j++){
            a[i][j]=0;
        }
    }
    for(int i=1;i<64;i++){
        int note=i;
        int j=0;
        while(note!=0){
            a[i][j]=note%2;
            note/=2;
            j++;
        }
    }
    string s;
    cin>>s;
    int count=0;
    for(int i=0;i<s.length();i++){
        int k=covert(s[i]);
       // cout<<k<<endl;

        for(int j=0;j<6;j++){
            if(a[k][j]==0){
                count++;
            }
        }

    }
    cout<<count<<endl;
    ll int ans=1;
    for(int i=0;i<count;i++){
        ans=(3*ans)%1000000007;
    }

    cout<<ans   ;
    //for(int i=0;i<6;i++){
    //    cout<<a[61][i]<<" ";
    //}

    return 0;
}


#include <bits/stdc++.h>
#define ultrax_007 ios_base::sync_with_stdio(false);cin.tie(NULL)
#define ll long long
#define pb push_back
#define pr pair<int, int>
#define mp make_pair
using namespace std;
int covert(char c){
    int x=c;
    if(x>=48 && x<=57){
        return x-48;
    }
    if(x>=65 && x<=90){
        return x-65+10;
    }
    if(x>=97 && x<=122){
        return x-97+36;
    }
    if(x=='-'){
        return 62;
    }
    if(x=='_'){
        return 63;
    }

}
long long power(int n,int k){
    if(n==0){return 0;}
    if(k==0){return 1;}
    if(n==1){return 1;}
    if(k==1){return 1;}
    return (n*power(n,k-1))%1000000007;

}
int main(){
    ultrax_007;
    int a[64][6];
    for(int i=0;i<64;i++){
        for(int j=0;j<6;j++){
            a[i][j]=0;
        }
    }
    for(int i=1;i<64;i++){
        int note=i;
        int j=0;
        while(note!=0){
            a[i][j]=note%2;
            note/=2;
            j++;
        }
    }
    string s;
    cin>>s;
    int count=0;
    for(int i=0;i<s.length();i++){
        int k=covert(s[i]);
       // cout<<k<<endl;

        for(int j=0;j<6;j++){
            if(a[k][j]==0){
                count++;
            }
        }

    }
    int mal=count;
    long long int ans=pow(3,mal);
    ans=ans%1000000007;
    cout<<ans;
    //for(int i=0;i<6;i++){
    //    cout<<a[61][i]<<" ";
    //}

    return 0;
}


////////////////////////////////////////
///////////////////////////////////////
#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
#include<utility>
#include<queue>
#include<stack>
#include<string>
#include<map>
using namespace std;
int a[69][69] ;
long long mod = 1000000007;
map <int ,int > m;
int main() {

    for (int i = 0; i < 64; i++) {
        for (int j = 0; j < 64; j++) {
            a[i][j] = i & j;
            m[a[i][j]] = (m[a[i][j]] + 1) %mod;
        }
    }

    string s;
    cin >> s;

    long long ans = 1 ;
    for (int i = 0; i < s.length(); i++) {
        if( (s[i] >= 'A' && s[i] <= 'Z')){
          ans = ((ans%mod)*(m[s[i] - 'A' + 10 ]%mod)) % mod ;
        }
        else if(s[i] >= 'a' && s[i] <= 'z'){
            ans = ((ans%mod)*(m[s[i] - 'a' + 36 ]%mod)) % mod ;

        }
        else if(s[i] == '-'){
            ans = ((ans%mod)*(m[62 ]%mod)) % mod ;
        }

        else if(s[i] == '_'){

            ans = ((ans%mod)*(m[63 ]%mod)) % mod ;
        }
        else{
            int index = s[i] - '0';
            ans = ((ans%mod)*(m[s[index] ]%mod)) % mod ;

        }

    }
    cout<< ans%mod ;

}


////////////////////////////////////////
///////////////////////////////////////
#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
#include<utility>
#include<queue>
#include<stack>
#include<string>
#include<map>
using namespace std;
int a[69][69] ;
long long mod = 1000000007;
map <int ,int > m;
int main() {

    for (int i = 0; i < 64; i++) {
        for (int j = 0; j < 64; j++) {
            a[i][j] = i & j;
            m[a[i][j]] = m[a[i][j]] + 1;
        }
    }

    string s;
    cin >> s;

    long long ans = 1 ;
    for (int i = 0; i < s.length(); i++) {
        if( (s[i] >= 'A' && s[i] <= 'Z')){
          ans = ((ans%mod)*(m[s[i] - 'A' + 10 ]%mod)) % mod ;
        }
        else if(s[i] >= 'a' && s[i] <= 'z'){
            ans = ((ans%mod)*(m[s[i] - 'a' + 36 ]%mod)) % mod ;

        }
        else if(s[i] == '-'){
            ans = ((ans%mod)*(m[62 ]%mod)) % mod ;
        }

        else if(s[i] == '_'){

            ans = ((ans%mod)*(m[63 ]%mod)) % mod ;
        }
        else{
            int index = s[i] - '0';
            ans = ((ans%mod)*(m[s[index] ]%mod)) % mod ;

        }

    }
    cout<< ans%mod ;

}


////////////////////////////////////////
///////////////////////////////////////
#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
#include<utility>
#include<queue>
#include<stack>
#include<string>
#include<map>
using namespace std;
int a[69][69] ;
long long mod = 1000000007;
map <int ,int > m;
int main() {

    for (int i = 0; i < 64; i++) {
        for (int j = 0; j < 64; j++) {
            a[i][j] = i & j;
            m[a[i][j]] = m[a[i][j]] + 1;
            m[i] = m[i] + 1;
            m[j] = m[j] + 1;
        }
    }

    string s;
    cin >> s;

    long long ans = 1 ;
    for (int i = 0; i < s.length(); i++) {
        if( (s[i] >= 'A' && s[i] <= 'Z')){
          ans = ((ans%mod)*(m[s[i] - 'A' + 10 ]%mod)) % mod ;
        }
        else if(s[i] >= 'a' && s[i] <= 'z'){
            ans = ((ans%mod)*(m[s[i] - 'a' + 36 ]%mod)) % mod ;

        }
        else if(s[i] == '-'){
            ans = ((ans%mod)*(m[62 ]%mod)) % mod ;
        }

        else if(s[i] == '_'){

            ans = ((ans%mod)*(m[63 ]%mod)) % mod ;
        }
        else{
            int index = s[i] - '0';
            ans = ((ans%mod)*(m[s[index] ]%mod)) % mod ;

        }

    }
    cout<< ans%mod ;

}


////////////////////////////////////////
///////////////////////////////////////
#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
#include<utility>
#include<queue>
#include<stack>
#include<string>
#include<map>
using namespace std;
int a[69][69] ;
long long mod = 1000000007;
map <int ,int > m;
int main() {

    for (int i = 0; i < 64; i++) {
        for (int j = 0; j < 64; j++) {
            a[i][j] = i & j;
            m[a[i][j]] = m[a[i][j]] + 1;
        }
    }

  for(int i=0 ;i < 64 ;i++) {
       m[i] = ( m[i]==0 ?  1 : m[i] );
    }

    string s;
    cin >> s;

    long long ans = 1 ;
    for (int i = 0; i < s.length(); i++) {
        if( (s[i] >= 'A' && s[i] <= 'Z')){
          ans = ((ans%mod)*(m[s[i] - 'A' + 10 ]%mod)) % mod ;
        }
        else if(s[i] >= 'a' && s[i] <= 'z'){
            ans = ((ans%mod)*(m[s[i] - 'a' + 36 ]%mod)) % mod ;

        }
        else if(s[i] == '-'){
            ans = ((ans%mod)*(m[62 ]%mod)) % mod ;
        }

        else if(s[i] == '_'){

            ans = ((ans%mod)*(m[63 ]%mod)) % mod ;
        }
        else{
            int index = s[i] - '0';
            ans = ((ans%mod)*(m[s[index] ]%mod)) % mod ;

        }

    }
    cout<< ans%mod ;

}


#include<stdio.h>
#include<string.h>
using namespace std;
const int MOD=1e9+7;
char s[100005];
int sum[65];
int change(char c)
{
    if(c>='0'&&c<='9')return c-'0';
    else if(c>='A'&&c<='Z')return c-'A'+10;
    else if(c>='a'&&c<='z')return c-'a'+36;
    else if(c=='-')return 62;
    else if(c=='_')return 63;
}
int main()
{
    for(int i=0;i<64;i++)
    {
        for(int j=0;j<64;j++)
        {
            sum[i&j]++;
        }
    }
    long long ans=1;
    scanf("%s",s);
    for(int i=0;i<strlen(s);i++)
    {
        ans=((ans*sum[change(s[i])]))%MOD;
    }
    printf("%d\n",ans);
}


#include <set>
#include <map>
#include <queue>
#include <cmath>
#include <vector>
#include <cstdio>
#include <utility>
#include <cstring>
#include <iostream>
#include <algorithm>

const int mod = 1e9 + 7;

inline int toInt(char x)
{
    if('a' <= x && x <= 'z') return x - 'a' + 36;
    if('A' <= x && x <= 'Z') return x - 'A' + 10;
    if('0' <= x && x <= '9') return x - '0';
    if('-' == x) return 62;
    if('_' == x) return 63;
}

int main()
{
    std::string str;
    std::cin >> str;
    std::vector<int> vec, dp(70);
    for(auto x : str) {
        vec.push_back(toInt(x));
    }
    for(int i = 0; i <= 63; i ++) {
        for(int j = 0; j <= 63; j ++) dp[i & j] ++;
    }
    long long ans = 1ll;
    for(auto x: vec) {
        ans *= dp[x];
        ans %= mod;
    }
    std::cout << ans << "\n";
}


#include <bits/stdc++.h>
using namespace std ;

//USUAL
#define s(n) scanf("%d",&n)
#define sl(n) scanf("%lld",&n)
#define sc(n) scanf("%c",&n)
#define forall(i,a,b) for(i=a;i<b;i++)

//STL
#define ii pair<int , int >
#define li pair < long long int , int >
#define mp make_pair
#define vi vector<int>
#define vvi vector< vi >
#define vl vector<long long int>
#define vvl vector< vl >
#define pb push_back
#define tr(it,c) for( typeof ( (c).begin() ) it = c.begin();it!=(c).end();++it)
#define max_const 1000000000000

int cnt[64] = {0} ;
map<char , int> M ;

int main()
{
	for(int i=0; i<64 ; i++)
	{
		for(int j = 0; j<64 ; j++)
		{
			cnt[ i & j ]++ ;
		}
	}

	for(int i=0;i<10;i++)
	{
		M[i + '0'] = i ;
	}

	for(int i = 10 ; i<=35 ; i++)
	{
		M[i + 'A' - 10] = i ;
	}

	for(int i = 36; i<=61 ; i++)
	{
		M[i + 'a' - 36] = i ;
	}

	M['-'] = 62 ;
	M['_'] = 63 ;

	string X ;
	cin>>X ;

	long long int ways =0 ;
	for(int i=0 ; i<X.length() ; i++)
	{
		if(i==0)
			ways = cnt[M[X[i]]] ;
		else
		{
			ways = ways * cnt[M[X[i]]] ;
			ways = ways % 1000000007  ;
		}
	}

	cout<<(ways%1000000007);

	return  0 ;
}


#include <bits/stdc++.h>
using namespace std ;

//USUAL
#define s(n) scanf("%d",&n)
#define sl(n) scanf("%lld",&n)
#define sc(n) scanf("%c",&n)
#define forall(i,a,b) for(i=a;i<b;i++)

//STL
#define ii pair<int , int >
#define li pair < long long int , int >
#define mp make_pair
#define vi vector<int>
#define vvi vector< vi >
#define vl vector<long long int>
#define vvl vector< vl >
#define pb push_back
#define tr(it,c) for( typeof ( (c).begin() ) it = c.begin();it!=(c).end();++it)
#define max_const 1000000000000

int cnt[64] ;
map<char , int> M ;

int main()
{
	for(int i=0; i<64 ; i++)
	{
		for(int j = 0; j<64 ; j++)
		{
			cnt[ i & j ]++ ;
		}
	}

	for(int i=0;i<10;i++)
	{
		M[i + '0'] = i ;
	}

	for(int i = 10 ; i<=35 ; i++)
	{
		M[i + 'A' - 10] = i ;
	}

	for(int i = 36; i<=61 ; i++)
	{
		M[i + 'a' - 36] = i ;
	}

	M['-'] = 62 ;
	M['_'] = 63 ;

	string X ;
	cin>>X ;

	long long int ways =0 ;
	for(int i=0 ; i<X.length() ; i++)
	{
		if(i==0)
			ways = cnt[M[X[i]]] ;
		else
		{
			ways = ways * cnt[M[X[i]]] ;
		}
	}

	cout<<(ways%1000000007);

	return  0 ;
}


#include <bits/stdc++.h>
using namespace std ;

//USUAL
#define s(n) scanf("%d",&n)
#define sl(n) scanf("%lld",&n)
#define sc(n) scanf("%c",&n)
#define forall(i,a,b) for(i=a;i<b;i++)

//STL
#define ii pair<int , int >
#define li pair < long long int , int >
#define mp make_pair
#define vi vector<int>
#define vvi vector< vi >
#define vl vector<long long int>
#define vvl vector< vl >
#define pb push_back
#define tr(it,c) for( typeof ( (c).begin() ) it = c.begin();it!=(c).end();++it)
#define max_const 1000000000000

int cnt[64] = {0} ;
map<char , int> M ;

int main()
{
	for(int i=0; i<64 ; i++)
	{
		for(int j = 0; j<64 ; j++)
		{
			cnt[ i & j ]++ ;
		}
	}

	for(int i=0;i<10;i++)
	{
		M[i + '0'] = i ;
	}

	for(int i = 10 ; i<=35 ; i++)
	{
		M[i + 'A' - 10] = i ;
	}

	for(int i = 36; i<=61 ; i++)
	{
		M[i + 'a' - 36] = i ;
	}

	M['-'] = 62 ;
	M['_'] = 63 ;

	string X ;
	cin>>X ;

	long long int ways =0 ;
	for(int i=0 ; i<X.length() ; i++)
	{
		if(i==0)
			ways = cnt[M[X[i]]] ;
		else
		{
			ways = ways * cnt[M[X[i]]] ;
		}
	}

	cout<<(ways%1000000007);

	return  0 ;
}


#include <bits/stdc++.h>
using namespace std ;

//USUAL
#define s(n) scanf("%d",&n)
#define sl(n) scanf("%lld",&n)
#define sc(n) scanf("%c",&n)
#define forall(i,a,b) for(i=a;i<b;i++)

//STL
#define ii pair<int , int >
#define li pair < long long int , int >
#define mp make_pair
#define vi vector<int>
#define vvi vector< vi >
#define vl vector<long long int>
#define vvl vector< vl >
#define pb push_back
#define tr(it,c) for( typeof ( (c).begin() ) it = c.begin();it!=(c).end();++it)
#define max_const 1000000000000

int cnt[64] ;
map<char , int> M ;

int main()
{
	for(int i=0; i<64 ; i++)
	{
		for(int j = 0; j<64 ; j++)
		{
			cnt[ i & j ]++ ;
		}
	}

	for(int i=0;i<10;i++)
	{
		M[i + '0'] = i ;
	}

	for(int i = 10 ; i<=35 ; i++)
	{
		M[i + 'A' - 10] = i ;
	}

	for(int i = 36; i<=61 ; i++)
	{
		M[i + 'a' - 36] = i ;
	}

	M['-'] = 62 ;
	M['_'] = 63 ;

	string X ;
	cin>>X ;

	long long int ways =0 ;
	for(int i=0 ; i<X.length() ; i++)
	{
		if(i==0)
			ways = cnt[M[X[i]]] ;
		else
		{
			ways = ways * cnt[M[X[i]]] ;
		}
	}

	cout<<ways;

	return  0 ;
}


#include <iostream>
#include <cstring>
using namespace std;

const long long mod = 1000000007;
long long v[800100];

long long j,x,n,i;
char s[100100];

void baza2(long long x)
{
    long long k=j+5;
    while(x)
        {
            v[k]=x%2;
            k--;
            x/=2;
        }
}

int main()
{
    cin.getline(s,100100);
    n=strlen(s);
    for(i=0,j=0; i<n; ++i,j+=6)
    {
        if(s[i]<='9' && s[i]>='0')
            x=s[i]-'0';
        else
        if(s[i]>='A' && s[i]<='Z')
            x=10+s[i]-'A';
        else
        if(s[i]>='a' && s[i]<='z')
            x=36+s[i]-'a';
        else
            if(v[i]=='-')
                x=62;
        else
            x=63;
        baza2(x);
    }
    long long nr=1;
    for(i=0; i<j; ++i)
        if(v[i]==0)
            nr=(nr*3)%mod;
    cout<<nr;
}


#include <iostream>
#include <cstring>
using namespace std;

const long long mod = 1000000007;
int v[800100];

int j,x,n,i;
char s[100100];

void baza2(int x)
{
    int k=j+5;
    while(x)
        {
            v[k]=x%2;
            k--;
            x/=2;
        }
}

int main()
{
    cin.getline(s,100100);
    n=strlen(s);
    for(i=0,j=0; i<n; ++i,j+=6)
    {
        if(s[i]<='9' && s[i]>='0')
            x=s[i]-'0';
        else
        if(s[i]>='A' && s[i]<='Z')
            x=10+s[i]-'A';
        else
        if(s[i]>='a' && s[i]<='z')
            x=36+s[i]-'a';
        else
            if(v[i]=='-')
                x=62;
        else
            x=63;
        baza2(x);
    }
    long long nr=1;
    for(i=0; i<j; ++i)
        if(v[i]==0)
            nr=(nr*3)%mod;
    cout<<nr;
}