#include <iostream>
using namespace std;

int main(int argc, char *argv[]) {
	int test;
	cin>>test;
	while(test!=0){
		int a,dis,con=0,mesas=0;
		string cad;
		string b="";
		cin>>a>>dis;
		cin>>cad;
		for(int i=0;i<a;i++){
			b+='0';
		}
		if(a==dis && cad == b){
			cout<<1<<"\n";
		}
		else if(a!=dis && cad==b){
			while(con!=a){
				if(con+dis+1>a){
					mesas++;
					break;
				}
				else{
					con+=dis+1;
					mesas++;
				}
			}
			cout<<mesas<<"\n";
		}
		else{
			for(int i=0;i<a;i++){
				if(cad[i]=='0'){
					con++;
					if(i==a-1){
						int c2=0;
						while(c2!=con){
							if(c2+dis+1>con){
								break;
							}
							else{
								c2+=dis+1;
								mesas++;
							}
						}
					}
				}
				else{
					if(con==i){
						int c2=0;
						while(c2!=con){
							if(c2+dis+1>con){
								break;
							}
							else{
								c2+=dis+1;
								mesas++;
							}
						}
					}
					else{
						if(con-dis*2>0){
							int c2=0;
							while(c2!=con){
								if(c2+dis+1>con){
									break;
								}
								else{
									c2+=dis+1;
									mesas++;
								}
							}
						}
					}
					con=0;
				}
			}
			cout<<mesas<<endl;
		}
		test--;
	}
	return 0;
}


#include <iostream>
using namespace std;

int main(int argc, char *argv[]) {
	int test;
	cin>>test;
	while(test!=0){
		int a,dis,con=0,mesas=0;
		string cad;
		string b="";
		cin>>a>>dis;
		cin>>cad;
		for(int i=0;i<a;i++){
			b+='0';
		}
		if(a==dis && cad == b){
			cout<<1<<"\n";
		}
		else if(a!=dis && cad==b){
			con=0;

			while(con!=a){
				if(con+dis+1>a){
					mesas++;
					break;
				}
				else{
					con+=dis+1;
					mesas++;
				}
			}
			cout<<mesas<<"\n";
		}
		else{
			for(int i=0;i<a;i++){
				if(cad[i]=='0'){
					con++;
					if(i==a-1){
						int c2=0;
						while(c2!=con){
							if(c2+dis+1>con){
								break;
							}
							else{
								c2+=dis+1;
								mesas++;
							}
						}
					}
				}
				else{
					if(con==i && con-dis>0){
						con-=dis;
						int c2=0;
						while(c2!=con){
							if(c2+dis+1>con){
								break;
							}
							else{
								c2+=dis+1;
								mesas++;
							}
						}
					}
					else{
						if(con>dis*2){
							con-=dis*2;
							int c2=0;
							while(c2!=con){
								if(c2+dis+1>con){
									break;
								}
								else{
									c2+=dis+1;
									mesas++;
								}
							}
						}
					}
					con=0;
				}
			}
			cout<<mesas<<endl;
		}
		test--;
	}
	return 0;
}


#include <iostream>
using namespace std;

int main(int argc, char *argv[]) {
	int test;
	cin>>test;
	while(test!=0){
		int a,dis;
		string cad;
		string b="";
		cin>>a>>dis;
		cin>>cad;
		for(int i=0;i<a;i++){
			b+='0';
		}
		if(a==dis && cad == b){
			cout<<1<<"\n";
		}
		else if(cad==b){
			if(dis==1){
				if(a%2==0){
					cout<<a/2<<"\n";
				}
				else{
					cout<<(a/2)+1<<"\n";
				}
			}
			else{
				cout<<a-(dis*2)<<"\n";
			}
		}
		else{
			int mesas=0,con=0;
			for(int i=0;i<a;i++){
				if(cad[i]=='0'){
					con++;
				}
				else{
					if(con-(dis*2)>=0){
						if(con-(dis*2)==0){
							mesas++;
						}
						else{
							mesas+=con-(dis*2);
						}
					}
					con=0;
				}
			}
			cout<<mesas<<"\n";
		}
		test--;
	}
	return 0;
}


#include <iostream>
using namespace std;

int main(int argc, char *argv[]) {
	int test;
	cin>>test;
	while(test!=0){
		int a,dis,con=0,mesas=0;
		string cad;
		string b="";
		cin>>a>>dis;
		cin>>cad;
		for(int i=0;i<a;i++){
			b+='0';
		}
		if(a==dis && cad == b){
			cout<<1<<"\n";
		}
		else if(a!=dis && cad==b){
			while(con!=a){
				if(con+dis+1>a){
					mesas++;
					break;
				}
				else{
					con+=dis+1;
					mesas++;
				}
			}
			cout<<mesas<<"\n";
		}
		else{
			for(int i=0;i<a;i++){
				if(cad[i]=='0'){
					con++;
					if(i==a-1){
						int c2=0;
						while(c2!=con){
							if(c2+dis+1>con){
								break;
							}
							else {
								c2+=dis+1;
								mesas++;
							}
						}
					}
				}
				else{
					if(con==i){
						int c2=0;
						if (con==dis+1){
							cout<<1<<endl;
						}
						else{
							while(c2!=con){
								if(c2+dis+1>con){
									break;
								}
								else if(c2+dis*2+1<=con){
									c2+=dis+1;
									mesas++;
								}
							}
						}
					}
					else{
						if (con==dis+1){
							cout<<1<<endl;
						}
						if(con-dis*2>0){
							int c2=0;
							while(c2!=con){
								if(c2+dis+1>con){
									break;
								}
								else if(c2+dis*2+1<=con){
									c2+=dis+1;
									mesas++;
								}
							}
						}
					}
					con=0;
				}
			}
			cout<<mesas<<endl;
		}
		test--;
	}
	return 0;
}


#include <iostream>
using namespace std;

int main(int argc, char *argv[]) {
	int test;
	cin>>test;
	while(test!=0){
		int a,dis,con=0,mesas=0;
		string cad;
		string b="";
		cin>>a>>dis;
		cin>>cad;
		for(int i=0;i<a;i++){
			b+='0';
		}
		if(a==dis && cad == b){
			cout<<1<<"\n";
		}
		else if(a!=dis && cad==b){
			while(con!=a){
				if(con+dis+1>a){
					mesas++;
					break;
				}
				else{
					con+=dis+1;
					mesas++;
				}
			}
			cout<<mesas<<"\n";
		}
		else{
			for(int i=0;i<a;i++){
				if(cad[i]=='0'){
					con++;
					if(i==a-1){
						int c2=0;
						while(c2!=con){
							if(c2+dis+1>con){
								break;
							}
							else{
								c2+=dis+1;
								mesas++;
							}
						}
					}
				}
				else{
					if(con==i){
						con-=dis;
						int c2=0;
						while(c2!=con){
							if(c2+dis+1>con && c2+1==con){
								mesas++;
								break;
							}
							else if(c2+dis+1>con && c2+1!=con){
								break;
							}
							else{
								c2+=dis+1;
								mesas++;
							}
						}
					}
					else{
						if(con-dis*2>0){
							con-=dis;
							int c2=0;
							while(c2!=con){
								if(c2+dis+1>con && c2+1==con){
									mesas++;
									c2++;
								}
								else if(c2+dis+1>con && c2+1!=con){
									break;
								}
								else{
									c2+=dis+1;
									mesas++;
								}
							}
						}
					}
					con=0;
				}
			}
			cout<<mesas<<endl;
		}
		test--;
	}
	return 0;
}


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

int main(int argc, char *argv[]) {
	int q;
	cin>>q;
	while(q--){
		int a,b;
		string c;
		cin>>a>>b>>c;

		vector<int>pos;
		for(int i=0;i<a;i++){
			if(c[i]=='1'){
				pos.push_back(i+1);
			}
		}
		if(pos.empty()){
			if(a==b){
			cout<<"1\n";
			}
			else{
				if(a%(b+1)!=0){
				cout<<(a/(b+1))+1<<"\n";
				}
				else{
					cout<<(a/(b+1))<<"\n";
				}
			}
			}
		else{
			if(pos.size()==1){

				cout<<(pos[0]-1)/(b+1) + (a-pos[0])/(b+1)<<"\n";
			}
			else{
				int con=0;
				if(pos[0]>1){
					con+=(pos[0]-1)/(b+1);
				}
				if(pos[pos.size()-1]!=a){
					con+=(a-pos[pos.size()-1])/(b+1);
				}
				for(int i=1;i<pos.size();i++){
					if(pos[i]-pos[i-1]!=1){
						con+=(pos[i]-pos[i-1]-1)/(b+1);
					}
				}
				cout<<con<<"\n";
			}
		}
	}
	return 0;
}


#include <iostream>
using namespace std;

int main(int argc, char *argv[]) {
	int test;
	cin>>test;
	while(test!=0){
		int a,dis,con=0,mesas=0;
		string cad;
		string b="";
		cin>>a>>dis;
		cin>>cad;
		for(int i=0;i<a;i++){
			b+='0';
		}
		if(a==dis && cad == b){
			cout<<1<<"\n";
		}
		else if(a!=dis && cad==b){
			con=0;

			while(con!=a){
				if(con+dis+1>a){
					mesas++;
					break;
				}
				else{
					con+=dis+1;
					mesas++;
				}
			}
			cout<<mesas<<"\n";
		}
		else{
			for(int i=0;i<a;i++){
				if(cad[i]=='0'){
					con++;
					if(i==a-1){
						int c2=0;
						while(c2!=con){
							if(c2+dis+1>con){
								break;
							}
							else{
								c2+=dis+1;
								mesas++;
							}
						}
					}
				}
				else{
					if(con==i){
						int c2=0;
						while(c2!=con){
							if(c2+dis+1>con){
								if(c2+dis>con){
									mesas--;
								}
								break;
							}
							else{
								c2+=dis+1;
								mesas++;
							}
						}
					}
					else{
						if(con-dis*2>0){

							int c2=0;
							while(c2!=con){
								if(c2+dis+1>con){
									if(c2+dis>con){
										mesas--;
									}
									break;
								}
								else{
									c2+=dis+1;
									mesas++;
								}
							}
						}
					}
					con=0;
				}
			}
			cout<<mesas<<"\n";
		}
		test--;
	}
	return 0;
}


#include <iostream>
using namespace std;

int main(int argc, char *argv[]) {
	int test;
	cin>>test;
	while(test!=0){
		int a,dis,con=0,mesas=0;
		string cad;
		string b="";
		cin>>a>>dis;
		cin>>cad;
		for(int i=0;i<a;i++){
			b+='0';
		}
		if(a==dis && cad == b){
			cout<<1<<"\n";
		}
		else if(a!=dis && cad==b){
			while(con!=a){
				if(con+dis+1>a){
					mesas++;
					break;
				}
				else{
					con+=dis+1;
					mesas++;
				}
			}
			cout<<mesas<<"\n";
		}
		else{
			for(int i=0;i<a;i++){
				if(cad[i]=='0'){
					con++;
					if(i==a-1){
						int c2=0;
						while(c2!=con){
							if(c2+dis+1>con){
								break;
							}
							else{
								c2+=dis+1;
								mesas++;
							}
						}
					}
				}
				else{6
					if(con==i){
						con-=dis;
						int c2=0;
						while(c2!=con){
							if(c2+dis+1>con && c2+1==con){
								mesas++;
								break;
							}
							else if(c2+dis+1>con && c2+1!=con){
								break;
							}
							else{
								c2+=dis+1;
								mesas++;
							}
						}
					}
					else{
						if(con-dis*2>0){
							con-=dis;
							int c2=0;
							while(c2!=con){
								if(c2+dis+1>con && c2+1==con){
									mesas++;
									c2++;
								}
								else if(c2+dis+1>con && c2+1!=con){
									break;
								}
								else{
									c2+=dis+1;
									mesas++;
								}
							}
						}
					}
					con=0;
				}
			}
			cout<<mesas<<endl;
		}
		test--;
	}
	return 0;
}


#include <iostream>
using namespace std;

int main(int argc, char *argv[]) {
	int test;
	cin>>test;
	while(test!=0){
		int a,dis;
		string cad;
		string b="";
		cin>>a>>dis;
		cin>>cad;
		for(int i=0;i<a;i++){
			b+='0';
		}
		if(a==dis && cad == b){
			cout<<1<<"\n";
		}
		else if(cad==b){
			cout<<a-(dis*2)<<"\n";
		}
		else{
			int mesas=0;
			for(int i=0;i<int(cad.size());i++){
				int j=i,con=0;
				if(i==0 && cad[i]=='0'){
					while(cad[j]=='0'){
						j++;
						con++;
					}
					i+=j-1;
					if(con-dis*2 >=0){
						if(con-dis*2==0){
							mesas+=1;
						}
						else{
							mesas+=con-dis*2;
						}
					}
				}
				else if(cad[i]=='0'){
					while(cad[j]=='0'){
						j++;
						con++;
					}
					i+=j-1;
					if(con-dis*2 >=0){
						if(con-dis*2==0){
							mesas+=1;
						}
						else{
							mesas+=con-dis*2;
						}
					}
				}
			}
			cout<<mesas<<"\n";
		}
		test--;
	}
	return 0;
}


#include<iostream>
using namespace std;
#include<vector>
#include<algorithm>
#include<stack>
#include<math.h>
int main() {

    int t;
    cin>>t;

    for(int i=0;i<t;i++)
    {
        int n,k;
        cin>>n>>k;
        string s;
        cin>>s;
        string ade="1";

        for(int j=0;j<k;j++)
            ade=ade+"0";

        s.insert(0, ade);
        reverse(ade.begin(),ade.end());
        s.append(ade);

        int cont=0;
        int ans=0;

        for(int j=0;j<s.length();j++)
        {
            if(s[j]=='0')
            {
                cont++;
            }
            else
            {
                cont=cont-k;
                if(cont>0)
                    ans=ans+cont/(k+1);
                cont=0;
            }
        }
        cout<<ans<<endl;
    }
}


#include<iostream>
using namespace std;
#include<vector>
#include<algorithm>
#include<stack>
#include<math.h>
int main() {

    int t;
    cin>>t;

    for(int i=0;i<t;i++)
    {
        int n,k;
        cin>>n>>k;
        string s;
        cin>>s;

        int cont=0;
        int strindex=0;
        int ans=0;

        for(int j=0;j<s.length();j++)
        {
            if(s[j]=='0')
            {
                cont++;
            }
            else
            {
                if(strindex!=0)
                    cont=cont-k;

                ans=ans+cont/(k+1);

                cont=0;
                strindex=j+1;
            }
        }

        if(cont!=0)
        {
            if(strindex!=0)
                cont=cont-k;
            int add=cont/(k+1);
            if((k+1)*add==cont)
                ans=ans+add;
            else
                ans=ans+add+1;

        }
        cout<<ans<<endl;

    }
}


#include<iostream>
using namespace std;
#include<vector>
#include<algorithm>
#include<stack>
#include<math.h>
int main() {

    int t;
    cin>>t;

    for(int i=0;i<t;i++)
    {
        int n,k;
        cin>>n>>k;
        string s;
        cin>>s;
        long long int lop=(int)pow(10, k);
        string ade=to_string(lop);

        s.insert(0, ade);
        reverse(ade.begin(),ade.end());
        s.append(ade);

        int cont=0;
        int ans=0;

        for(int j=0;j<s.length();j++)
        {
            if(s[j]=='0')
            {
                cont++;
            }
            else
            {
                cont=cont-k;
                if(cont>0)
                    ans=ans+cont/(k+1);
                cont=0;
            }
        }
        cout<<ans<<endl;
    }
}


#include<iostream>
using namespace std;
#include<vector>
#include<algorithm>
#include<stack>
#include<math.h>
int main() {

    int t;
    cin>>t;

    for(int i=0;i<t;i++)
    {
        int n,k;
        cin>>n>>k;
        string s;
        cin>>s;

        int cont=0;
        int strindex=0;
        int ans=0;

        for(int j=0;j<s.length();j++)
        {
            if(s[j]=='0')
            {
                cont++;
            }
            else
            {
                if(strindex!=0)
                    cont=cont-k;

                ans=ans+cont/(k+1);

                cont=0;
                strindex=j+1;
            }
        }

        if(cont!=0)
        {
            if(strindex!=0)
                cont=cont-k;
            int add=cont/(k+1);
            if((k+1)*add==cont)
                ans=ans+add;
            else
                ans=ans+add+1;

        }
        cout<<ans<<endl;
    }
}


#include<iostream>
using namespace std;
#include<vector>
#include<algorithm>
#include<stack>
#include<math.h>
int main() {

    int t;
    cin>>t;

    for(int i=0;i<t;i++)
    {
        int n,k;
        cin>>n>>k;
        string s;
        cin>>s;

        int cont=0;
        int strindex=0;
        int ans=0;

        for(int j=0;j<s.length();j++)
        {
            if(s[j]=='0')
            {
                cont++;
            }
            else
            {
                if(strindex!=0)
                    cont=cont-k;

                ans=ans+cont/(k+1);

                cont=0;
                strindex=j+1;
            }
        }

        if(cont!=0)
        {
            if(strindex!=0)
                cont=cont-k;
            if(cont<0)
                cont=0;
            int add=cont/(k+1);
            if((k+1)*add==cont)
                ans=ans+add;
            else
                ans=ans+add+1;

        }
        cout<<ans<<endl;

    }
}


#include<iostream>
using namespace std;
#include<vector>
#include<algorithm>
#include<stack>
#include<math.h>
int main() {

    int t;
    cin>>t;

    for(int i=0;i<t;i++)
    {
        long long n,k;
        cin>>n>>k;
        string s;
        cin>>s;

        long long cont=0;
        long long strindex=0;
        long long ans=0;

        for(long long j=0;j<s.length();j++)
        {
            if(s[j]=='0')
            {
                cont++;
            }
            else
            {
                if(strindex!=0)
                    cont=cont-k;

                ans=ans+cont/(k+1);

                cont=0;
                strindex=j+1;
            }
        }

        if(cont!=0)
        {
            if(strindex!=0)
                cont=cont-k;
            long long add=cont/(k+1);
            if((k+1)*add==cont)
                ans=ans+add;
            else
                ans=ans+add+1;

        }
        cout<<ans<<endl;
    }
}


#include<iostream>
using namespace std;
#include<vector>
#include<algorithm>
#include<stack>
#include<math.h>
int main() {

    int t;
    cin>>t;

    for(int i=0;i<t;i++)
    {
        int n,k;
        cin>>n>>k;
        string s;
        cin>>s;
        int lop=(int)pow(10, k);
        string ade=to_string(lop);

        s.insert(0, ade);
        reverse(ade.begin(),ade.end());
        s.append(ade);

        int cont=0;
        int ans=0;

        for(int j=0;j<s.length();j++)
        {
            if(s[j]=='0')
            {
                cont++;
            }
            else
            {
                cont=cont-k;
                ans=ans+cont/(k+1);
                cont=0;
            }
        }
        cout<<ans<<endl;
    }
}


#include<iostream>
using namespace std;
#include<vector>
#include<algorithm>
#include<stack>
#include<math.h>
int main() {

    int t;
    cin>>t;

    for(int i=0;i<t;i++)
    {
        int n,k;
        cin>>n>>k;
        string s;
        cin>>s;
        int lop=(int)pow(10, k);
        string ade=to_string(lop);

        s.insert(0, ade);
        reverse(ade.begin(),ade.end());
        s.append(ade);

        int cont=0;
        int ans=0;

        for(int j=0;j<s.length();j++)
        {
            if(s[j]=='0')
            {
                cont++;
            }
            else
            {
                cont=cont-k;
                if(cont>0)
                    ans=ans+cont/(k+1);
                cont=0;
            }
        }
        cout<<ans<<endl;
    }
}


#include<iostream>
using namespace std;
#include<vector>
#include<algorithm>
#include<stack>
#include<math.h>
int main() {

    int t;
    cin>>t;

    for(int i=0;i<t;i++)
    {
        int n,k;
        cin>>n>>k;
        string s;
        cin>>s;
        int lop=(int)pow(10, k);
        string ade=to_string(lop);

        s.insert(0, ade);
        reverse(ade.begin(),ade.end());
        s.append(ade);

        int cont=0;
        int ans=0;

        for(int j=0;j<s.length();j++)
        {
            if(s[j]=='0')
            {
                cont++;
            }
            else
            {
                ans=ans+cont/(k+1);
                cont=0;
            }
        }
        cout<<ans<<endl;
    }
}


#include<iostream>
using namespace std;
#include<vector>
#include<algorithm>
#include<stack>
#include<math.h>
int main() {

    int t;
    cin>>t;

    for(int i=0;i<t;i++)
    {
        int n,k;
        cin>>n>>k;
        string s;
        cin>>s;
        string ade;

        ade=string(k,'0').append(ade);
        ade.insert(0, "1");

        s.insert(0, ade);
        reverse(ade.begin(),ade.end());
        s.append(ade);

        int cont=0;
        int ans=0;

        for(int j=0;j<s.length();j++)
        {
            if(s[j]=='0')
            {
                cont++;
            }
            else
            {
                cont=cont-k;
                if(cont>0)
                    ans=ans+cont/(k+1);
                cont=0;
            }
        }
        cout<<ans<<endl;
    }
}


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

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t, n, next, last, i, k, ans;
    string s;
    cin>>t;
    while (t--)
    {
        cin>>n>>k;
        cin>>s;
        last = -1;
        i=0;
        ans = 0;
        while (i < n)
        {
            if (s[i] == '1')
            {
                last = i;
                i += (k+1);
            }
            else if (s[i] == '0' && (last == -1 || (i-last) > k))
            {
                next = -1;
                for (int j=i+1; j<=(i+k); j++)
                {
                    if (j >= n)
                    break;
                    if (s[j] == '1')
                    {
                        next = j;
                        break;
                    }
                }
                if (next == -1 || (next-i) > k)
                {
                    s[i] = '1';
                    i += (k+1);
                    ans += 1;
                }
                else
                {
                    i += 1;
                }
            }
            else
            {
                i += 1;
            }
        }
        // cout<<s<<endl<<"ans = ";
        cout<<ans<<endl;
    }
    return 0;
}


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

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t, n, cnt, last, i, k, ans;
    string s;
    cin>>t;
    while (t--)
    {
        cin>>n>>k;
        cin>>s;
        last = -1;
        i=0;
        ans = 0;
        cnt = 0;
        while (i < n)
        {
            if (s[i] == '1')
            {
                ans += (cnt/(k+1));
                cnt = 0;
            }
            else
            {
                cnt += 1;
            }
            i += 1;
        }
        // cout<<"ans = ";
        if (cnt == n && ans == 0)
        {
            if (n<=k)
            ans = 1;
            else
            {
                ans += cnt/(k+1);
            }
        }
        cout<<ans<<endl;
    }
    return 0;
}


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

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t, n, next, last, i, k, ans;
    string s;
    cin>>t;
    while (t--)
    {
        cin>>n>>k;
        cin>>s;
        last = -1;
        i=0;
        ans = 0;
        while (i < n)
        {
            if (s[i] == '1')
            {
                last = i;
                i += (k+1);
            }
            else if (s[i] == '0' && (last == -1 || (i-last) > k))
            {
                next = -1;
                for (int j=i+1; j<=(i+k); j++)
                {
                    if (s[j] == '1')
                    {
                        next = j;
                        break;
                    }
                }
                if (next == -1 || (next-i) > k)
                {
                    s[i] = '1';
                    i += (k+1);
                    ans += 1;
                }
                else
                {
                    i += 1;
                }
            }
            else
            {
                i += 1;
            }
        }
        // cout<<s<<endl<<"ans = ";
        cout<<ans<<endl;
    }
    return 0;
}


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

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t, n, cnt, tot, last, i, k, ans;
    string s;
    cin>>t;
    while (t--)
    {
        cin>>n>>k;
        cin>>s;
        last = -1;
        i=0;
        ans = 0;
        cnt = tot =  0;
        while (i < n)
        {
            if (s[i] == '0')
            {
                cnt += 1;
            }
            else if (s[i] == '1')
            {
                cnt = 0;
                last = i;
            }
            if (i == (n-1) && cnt == n)
            {
                ans = 1;
            }
            else if ((last == -1 || i == (n-1)) && cnt > k && s[i] == '0')
            {
                ans += 1;
                last = i-k;
                cnt = k;
            }
            else if (last >= 0 && cnt >= (2*k + 1) && s[i] == '0')
            {
                last = i-k;
                cnt = k;
                ans += 1;
            }
            i += 1;
        }
        // if (ans == 0 && n <= k && tot == n)
        // ans = 1;
        // cout<<"ans = ";
        cout<<ans<<endl;
    }
    return 0;
}


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

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t, n, next, last, i, k, ans;
    string s;
    cin>>t;
    while (t--)
    {
        cin>>n>>k;
        cin>>s;
        last = -1;
        i=0;
        ans = 0;
        while (i < n)
        {
            if (s[i] == '1')
            {
                last = i;
                i += (k+1);
            }
            else if (s[i] == '0' && (last == -1 || (i-last) > k))
            {
                next = -1;
                for (int j=i+1; j<n; j++)
                {
                    if (s[j] == '1')
                    {
                        next = j;
                        break;
                    }
                }
                if (next == -1 || (next-i) > k)
                {
                    s[i] = '1';
                    i += (k+1);
                    ans += 1;
                }
                else
                {
                    i += 1;
                }
            }
            else
            {
                i += 1;
            }
        }
        // cout<<s<<endl<<"ans = ";
        cout<<ans<<endl;
    }
    return 0;
}


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

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t, n, cnt, tot, last, i, k, ans;
    string s;
    cin>>t;
    while (t--)
    {
        cin>>n>>k;
        cin>>s;
        last = -1;
        i=0;
        ans = 0;
        cnt = tot =  0;
        while (i < n)
        {
            if (s[i] == '0')
            {
                cnt += 1;
                tot += 1;
            }
            if (s[i] == '1' || i == (n-1))
            {
                ans += (cnt/(k+1));
                cnt = 0;
            }
            i += 1;
        }
        if (ans == 0 && n <= k && tot == n)
        ans = 1;
        // cout<<"ans = ";
        cout<<ans<<endl;
    }
    return 0;
}


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

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t, n, cnt, tot, last, i, k, ans;
    string s;
    cin>>t;
    while (t--)
    {
        cin>>n>>k;
        cin>>s;
        last = -1;
        i=0;
        ans = 0;
        cnt = tot =  0;
        while (i < n)
        {
            if (s[i] == '0')
            {
                cnt += 1;
                tot += 1;
            }
            else if (s[i] == '1')
            {
                if (last >= 0)
                ans += (cnt/(2*k+1));
                else
                ans += (cnt/(k+1));
                cnt = 0;
                last = i;
            }
            if (i == (n-1))
            {
                if (cnt < n)
                {
                    ans += (cnt/(k+1));
                }
                else
                {
                    ans = 1;
                    ans += ((cnt-1)/(k+1));
                }
            }
            i += 1;
        }
        // if (ans == 0 && n <= k && tot == n)
        // ans = 1;
        // cout<<"ans = ";
        cout<<ans<<endl;
    }
    return 0;
}


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

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t, n, cnt, tot, last, i, k, ans;
    string s;
    cin>>t;
    while (t--)
    {
        cin>>n>>k;
        cin>>s;
        last = -1;
        i=0;
        ans = 0;
        cnt = tot =  0;
        while (i < n)
        {
            if (s[i] == '0')
            {
                cnt += 1;
                tot += 1;
            }
            else if (s[i] == '1')
            {
                ans += (cnt/(k+1));
                cnt = 0;
            }
            if (i == (n-1))
            {
                if (cnt < n)
                {
                    ans += (cnt/(k+1));
                }
                else
                {
                    ans = 1;
                    ans += ((cnt-1)/(k+1));
                }
            }
            i += 1;
        }
        // if (ans == 0 && n <= k && tot == n)
        // ans = 1;
        // cout<<"ans = ";
        cout<<ans<<endl;
    }
    return 0;
}


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

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t, n, k, last, ans;
    bool flag;
    string s;
    cin>>t;
    while (t--)
    {
        cin>>n>>k;
        cin>>s;
        ans = 0;
        for (int i=0; i<n; i++)
        {
            if (s[i] == '1')
            {
                i += k;
                continue;
            }
            flag = 0;
            for(int j=1; j<=k; j++)
            {
                if (s[i+j] == '1')
                {
                    flag = 1;
                    last = i;
                }
            }
            if (flag == 0)
            {
                s[i] = '1';
                ans += 1;
                i = i+k;
            }
            else
            {
                i = last+k;
            }
        }
        cout<<ans<<endl;
    }
    return 0;
}


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

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t, n, cnt, last, i, k, ans;
    string s;
    cin>>t;
    while (t--)
    {
        cin>>n>>k;
        cin>>s;
        last = -1;
        i=0;
        ans = 0;
        cnt = 0;
        while (i < n)
        {
            if (s[i] == '1')
            {
                ans += (cnt/(k+1));
                cnt = 0;
            }
            else
            {
                cnt += 1;
            }
            i += 1;
        }
        // cout<<"ans = ";
        if (ans == 0)
        {
            if (n<=k && cnt == n)
            ans = 1;
            else
            {
                ans += cnt/(k+1);
            }
        }
        cout<<ans<<endl;
    }
    return 0;
}


//                      YATIN KWATRA

// AC BAKSHI RABBA

#include <bits/stdc++.h>
#define ll                      long long
#define ld                      long double
#define ull                     unsigned long long
#define FIO                     ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl                    "\n"
#define fo(i,a,b)               for(int i = a; i<=b ; i++)
#define rfo(i,a,b)              for(int i = a; i>=b ; i--)
#define vii                      vector<int>
#define vll                     vector<ll>
#define pq                      priority_queue
#define uom                      unordered_map
#define all(v)                  v.begin(),v.end()
#define mp                      make_pair
#define pb                      push_back
#define pob                     pop_back
#define ff                      first
#define ss                      second
#define pii                     pair<int,int>
#define pll                     pair<long,long>
#define mll                     map<ll,ll>
#define mii                     map<int,int>
#define vvii                    vector<vii>
#define vvll                    vector<vll>
#define mod                     1000000007
#define pi                      3.1415926535897932384626433832795
// #define node                    Node

using namespace std;

void INPUT() {

    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}

void solve()
{

        int n,k;
        cin >> n >> k;

        string s;
        cin >> s;

        if(s == "0" or s == "00")
        {
          cout << 1 << endl;
          return;
        }

        int tot = 0, cnt = 0, last = -1,neww = -1;

       int i = 0;
       int ini = 1;

       int co = 0;

       while(i<n)
       {

         if(s[i]=='0') co++;

         if(s[i] == '0') cnt++;
         else
         {
          cnt = 0;
          ini = 0;
         }

         if(ini == 1)
         {
           if(cnt == k+1)
           {
             cnt = k;
             //s[i-k] = '1';
             tot++;
             ini = 0;
           }
           i++;
           continue;
         }
         else if(cnt == k+1)
         {
           int j = i+1;

           int co = 0;
           while(j<n and s[j] == '0')
           {
             co++;
             if(co == k) break;
             j++;
           }

           if(co == k)
           {
            tot++;
            s[i] = '1';
            cnt = k;
           }
           else if(j == n)
           {
            tot++;
            break;
           }
           else cnt = 0;
           i = j+1;
           continue;
         }
         i++;
       }

       if(tot == 0 and co == n) tot++;

       cout << tot << endl;
}
int main() {

    FIO
    INPUT();

    int t;
    t = 1;
    cin >> t;

    while(t--)
    {
       solve();
    }
    return 0;
}


//                      YATIN KWATRA

// AC BAKSHI RABBA

#include <bits/stdc++.h>
#define ll                      long long
#define ld                      long double
#define ull                     unsigned long long
#define FIO                     ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl                    "\n"
#define fo(i,a,b)               for(int i = a; i<=b ; i++)
#define rfo(i,a,b)              for(int i = a; i>=b ; i--)
#define vii                      vector<int>
#define vll                     vector<ll>
#define pq                      priority_queue
#define uom                      unordered_map
#define all(v)                  v.begin(),v.end()
#define mp                      make_pair
#define pb                      push_back
#define pob                     pop_back
#define ff                      first
#define ss                      second
#define pii                     pair<int,int>
#define pll                     pair<long,long>
#define mll                     map<ll,ll>
#define mii                     map<int,int>
#define vvii                    vector<vii>
#define vvll                    vector<vll>
#define mod                     1000000007
#define pi                      3.1415926535897932384626433832795
// #define node                    Node

using namespace std;

void INPUT() {

    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}

void solve()
{

        int n,k;
        cin >> n >> k;

        string s;
        cin >> s;

        if(s == "0" or s == "00")
        {
          cout << 1 << endl;
          return;
        }

        int tot = 0, cnt = 0, last = -1,neww = -1;

       int i = 0;
       int ini = 1;

       while(i<n)
       {
         if(s[i] == '0') cnt++;
         else cnt = 0;

         if(ini == 1)
         {
           if(cnt == k+1)
           {
             cnt = 0;
             s[i] = '1';
             tot++;
             ini = 0;
           }
           i++;
           continue;
         }
         else if(cnt == k+1)
         {
           int j = i+1;

           int co = 0;
           while(j<n and s[j] == '0')
           {
             co++;
             if(co == k) break;
             j++;
           }

           if(co == k)
           {
            tot++;
            s[i] = '1';
            i = j+1;
           }
           else if(j == n)
           {
            tot++;
            break;
           }
           continue;
         }
         i++;
       }

       cout << tot << endl;
}
int main() {

    FIO
    INPUT();

    int t;
    t = 1;
    cin >> t;

    while(t--)
    {
       solve();
    }
    return 0;
}


//                      YATIN KWATRA

// AC BAKSHI RABBA

#include <bits/stdc++.h>
#define ll                      long long
#define ld                      long double
#define ull                     unsigned long long
#define FIO                     ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl                    "\n"
#define fo(i,a,b)               for(int i = a; i<=b ; i++)
#define rfo(i,a,b)              for(int i = a; i>=b ; i--)
#define vii                      vector<int>
#define vll                     vector<ll>
#define pq                      priority_queue
#define uom                      unordered_map
#define all(v)                  v.begin(),v.end()
#define mp                      make_pair
#define pb                      push_back
#define pob                     pop_back
#define ff                      first
#define ss                      second
#define pii                     pair<int,int>
#define pll                     pair<long,long>
#define mll                     map<ll,ll>
#define mii                     map<int,int>
#define vvii                    vector<vii>
#define vvll                    vector<vll>
#define mod                     1000000007
#define pi                      3.1415926535897932384626433832795
// #define node                    Node

using namespace std;

void INPUT() {

    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}

void solve()
{

        int n,k;
        cin >> n >> k;

        string s;
        cin >> s;

        if(s == "0" or s == "00")
        {
          cout << 1 << endl;
          return;
        }

        int tot = 0, cnt = 0, last = -1,neww = -1;

        fo(i,0,n-1)
        {
          if(s[i] == '1') cnt = 0;
          else cnt++;

          if(neww == -1 and cnt == i+1)
          {
            if(cnt == k+1) {

              tot++;
              s[i-k] = '1';
              cnt = k;
              neww = 0;

            }
          }
          else if(s[i] == '0')
          {
            if(cnt == (2*k+1))
            {
              cnt = k;
              s[i-k] = '1';
              tot++;
            }
          }
        }

        cnt = 0;
        rfo(i,n-1,0)
        {
          if(s[i] == '0') cnt++;
          else break;
        }

        if(cnt>=(k+1)) tot++;

       // cout << cnt << endl;
       // cout << s << endl;

       cout << tot << endl;
}
int main() {

    FIO
    INPUT();

    int t;
    t = 1;
    cin >> t;

    while(t--)
    {
       solve();
    }
    return 0;
}


//                      YATIN KWATRA

// AC BAKSHI RABBA

#include <bits/stdc++.h>
#define ll                      long long
#define ld                      long double
#define ull                     unsigned long long
#define FIO                     ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl                    "\n"
#define fo(i,a,b)               for(int i = a; i<=b ; i++)
#define rfo(i,a,b)              for(int i = a; i>=b ; i--)
#define vii                      vector<int>
#define vll                     vector<ll>
#define pq                      priority_queue
#define uom                      unordered_map
#define all(v)                  v.begin(),v.end()
#define mp                      make_pair
#define pb                      push_back
#define pob                     pop_back
#define ff                      first
#define ss                      second
#define pii                     pair<int,int>
#define pll                     pair<long,long>
#define mll                     map<ll,ll>
#define mii                     map<int,int>
#define vvii                    vector<vii>
#define vvll                    vector<vll>
#define mod                     1000000007
#define pi                      3.1415926535897932384626433832795
// #define node                    Node

using namespace std;

void INPUT() {

    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}

void solve()
{

        int n,k;
        cin >> n >> k;

        string s;
        cin >> s;

        if(s == "0" or s == "00")
        {
          cout << 1 << endl;
          return;
        }

        int tot = 0, cnt = 0, last = -1,neww = -1;

       int i = 0;
       int ini = 1;

       while(i<n)
       {

        if(s[i] == '1')
        {
          i = i+k+1;
          continue;
        }
        else
        {
          int cnt = 0;

          int j = i+1;

          while(j<n and j<(i+k+1))
          {
            if(s[j] == '1')
            {
              cnt=1;
              break;
            }
            j++;
          }

          if(cnt == 0)
          {
            tot++;
            i = j;
          }
          else i++;
        }

       }

       cout << tot << endl;
}
int main() {

    FIO
    INPUT();

    int t;
    t = 1;
    cin >> t;

    while(t--)
    {
       solve();
    }
    return 0;
}


//                      YATIN KWATRA

// AC BAKSHI RABBA

#include <bits/stdc++.h>
#define ll                      long long
#define ld                      long double
#define ull                     unsigned long long
#define FIO                     ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl                    "\n"
#define fo(i,a,b)               for(int i = a; i<=b ; i++)
#define rfo(i,a,b)              for(int i = a; i>=b ; i--)
#define vii                      vector<int>
#define vll                     vector<ll>
#define pq                      priority_queue
#define uom                      unordered_map
#define all(v)                  v.begin(),v.end()
#define mp                      make_pair
#define pb                      push_back
#define pob                     pop_back
#define ff                      first
#define ss                      second
#define pii                     pair<int,int>
#define pll                     pair<long,long>
#define mll                     map<ll,ll>
#define mii                     map<int,int>
#define vvii                    vector<vii>
#define vvll                    vector<vll>
#define mod                     1000000007
#define pi                      3.1415926535897932384626433832795
// #define node                    Node

using namespace std;

void INPUT() {

    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}

void solve()
{

        int n,k;
        cin >> n >> k;

        string s;
        cin >> s;

        if(s == "0" or s == "00")
        {
          cout << 1 << endl;
          return;
        }

        int tot = 0, cnt = 0, last = -1,neww = -1;

       int i = 0;
       int ini = 1;

       while(i<n)
       {

        if(s[i] == '1')
        {
          i = i+k+1;
          continue;
        }
        else
        {
          int cnt = 0;

          int j = i+1;

          while(j<n and j<(i+k+1))
          {
            if(s[j] == '1')
            {
              cnt=1;
              break;
            }
            j++;
          }

          if(cnt == 0)
          {
            tot++;
          }
          i = j;
        }

       }

       cout << tot << endl;
}
int main() {

    FIO
    INPUT();

    int t;
    t = 1;
    cin >> t;

    while(t--)
    {
       solve();
    }
    return 0;
}


//                      YATIN KWATRA

// AC BAKSHI RABBA

#include <bits/stdc++.h>
#define ll                      long long
#define ld                      long double
#define ull                     unsigned long long
#define FIO                     ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl                    "\n"
#define fo(i,a,b)               for(int i = a; i<=b ; i++)
#define rfo(i,a,b)              for(int i = a; i>=b ; i--)
#define vii                      vector<int>
#define vll                     vector<ll>
#define pq                      priority_queue
#define uom                      unordered_map
#define all(v)                  v.begin(),v.end()
#define mp                      make_pair
#define pb                      push_back
#define pob                     pop_back
#define ff                      first
#define ss                      second
#define pii                     pair<int,int>
#define pll                     pair<long,long>
#define mll                     map<ll,ll>
#define mii                     map<int,int>
#define vvii                    vector<vii>
#define vvll                    vector<vll>
#define mod                     1000000007
#define pi                      3.1415926535897932384626433832795
// #define node                    Node

using namespace std;

void INPUT() {

    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}

void solve()
{

        int n,k;
        cin >> n >> k;

        string s;
        cin >> s;

        if(s == "0" or s == "00")
        {
          cout << 1 << endl;
          return;
        }

        int tot = 0, cnt = 0, last = -1,neww = -1;

       int i = 0;
       int ini = 1;

       while(i<n)
       {

        if(s[i] == '1')
        {
          i = i+k+1;
          continue;
        }
        else
        {
          int cnt = 0;

          int j = i+1;

          while(j<n and cnt!=k and s[i] == '0')
          {
            cnt++;
            j++;
          }

          if(cnt == k)
          {
            tot++;
            i = j;
          }
          else i++;
        }

       }

       cout << tot << endl;
}
int main() {

    FIO
    INPUT();

    int t;
    t = 1;
    cin >> t;

    while(t--)
    {
       solve();
    }
    return 0;
}


//                      YATIN KWATRA

// AC BAKSHI RABBA

#include <bits/stdc++.h>
#define ll                      long long
#define ld                      long double
#define ull                     unsigned long long
#define FIO                     ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl                    "\n"
#define fo(i,a,b)               for(int i = a; i<=b ; i++)
#define rfo(i,a,b)              for(int i = a; i>=b ; i--)
#define vii                      vector<int>
#define vll                     vector<ll>
#define pq                      priority_queue
#define uom                      unordered_map
#define all(v)                  v.begin(),v.end()
#define mp                      make_pair
#define pb                      push_back
#define pob                     pop_back
#define ff                      first
#define ss                      second
#define pii                     pair<int,int>
#define pll                     pair<long,long>
#define mll                     map<ll,ll>
#define mii                     map<int,int>
#define vvii                    vector<vii>
#define vvll                    vector<vll>
#define mod                     1000000007
#define pi                      3.1415926535897932384626433832795
// #define node                    Node

using namespace std;

void INPUT() {

    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}

void solve()
{

        int n,k;
        cin >> n >> k;

        string s;
        cin >> s;

        if(s == "0" or s == "00")
        {
          cout << 1 << endl;
          return;
        }

        int tot = 0, cnt = 0, last = -1,neww = -1;

       int i = 0;
       int ini = 1;

       while(i<n)
       {
         if(s[i] == '0') cnt++;
         else cnt = 0;

         if(ini == 1)
         {
           if(cnt == k+1)
           {
             cnt = 0;
             s[i] = '1';
             tot++;
             ini = 0;
           }
           i++;
           continue;
         }
         else if(cnt == k+1)
         {
           int j = i+1;

           int co = 0;
           while(j<n and s[i] == '0')
           {
             co++;
             if(co == k) break;
             j++;
           }

           if(co == k)
           {
            tot++;
            s[i] = '1';
            i = j+1;
           }
           else if(j == n)
           {
            tot++;
            break;
           }
           continue;
         }
         i++;
       }

       cout << tot << endl;
}
int main() {

    FIO
    INPUT();

    int t;
    t = 1;
    cin >> t;

    while(t--)
    {
       solve();
    }
    return 0;
}


//                      YATIN KWATRA

// AC BAKSHI RABBA

#include <bits/stdc++.h>
#define ll                      long long
#define ld                      long double
#define ull                     unsigned long long
#define FIO                     ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl                    "\n"
#define fo(i,a,b)               for(int i = a; i<=b ; i++)
#define rfo(i,a,b)              for(int i = a; i>=b ; i--)
#define vii                      vector<int>
#define vll                     vector<ll>
#define pq                      priority_queue
#define uom                      unordered_map
#define all(v)                  v.begin(),v.end()
#define mp                      make_pair
#define pb                      push_back
#define pob                     pop_back
#define ff                      first
#define ss                      second
#define pii                     pair<int,int>
#define pll                     pair<long,long>
#define mll                     map<ll,ll>
#define mii                     map<int,int>
#define vvii                    vector<vii>
#define vvll                    vector<vll>
#define mod                     1000000007
#define pi                      3.1415926535897932384626433832795
// #define node                    Node

using namespace std;

void INPUT() {

    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}

void solve()
{

        int n,k;
        cin >> n >> k;

        string s;
        cin >> s;

        if(s == "0" or s == "00")
        {
          cout << 1 << endl;
          return;
        }

        int tot = 0, cnt = 0, last = -1,neww = -1;

       int i = 0;
       int ini = 1;

       while(i<n)
       {
         if(s[i] == '0') cnt++;
         else
         {
          cnt = 0;
          ini = 0;
         }

         if(ini == 1)
         {
           if(cnt == k+1)
           {
             cnt = k;
             //s[i-k] = '1';
             tot++;
             ini = 0;
           }
           i++;
           continue;
         }
         else if(cnt == k+1)
         {
           int j = i+1;

           int co = 0;
           while(j<n and s[j] == '0')
           {
             co++;
             if(co == k) break;
             j++;
           }

           if(co == k)
           {
            tot++;
            s[i] = '1';
            cnt = k;
           }
           else if(j == n)
           {
            tot++;
            break;
           }
           else cnt = 0;
           i = j+1;
           continue;
         }
         i++;
       }

       cout << tot << endl;
}
int main() {

    FIO
    INPUT();

    int t;
    t = 1;
    cin >> t;

    while(t--)
    {
       solve();
    }
    return 0;
}


n = raw_input()
ans = 0
a = []
for i in xrange(len(n)):
    if n[i]=='*':
        a.append(i)
for i in a:
    for j in xrange(i+3,len(n)+1):
        if j==len(n) or n[j]=='*' or n[j] == '+':
           #print n[:i+1]+'('+n[i+1:j]+')'+n[j:]
            #print str(i)+' '+str(j)
            s = eval(n[:i+1]+'('+n[i+1:j]+')'+n[j:])
            ans = max(ans,s)
for j in a:
    for i in xrange(j-2):
        if n[i] in '0123456789':
            #print n[:i]+'('+n[i:j]+')'+n[j:]
            s = eval(n[:i]+'('+n[i:j]+')'+n[j:])
            ans = max(ans,s)
ans = max(ans,eval(n))
print ans


n = raw_input()
#n = '2*'*15+'1+'*400+'5'
ans = 0
a = [-1]
for i in xrange(len(n)):
    if n[i]=='*':
        a.append(i)
        a.append(len(n))
for i in a:
    for j in a:
        if j>i:
           #print n[:i+1]+'('+n[i+1:j]+')'+n[j:]
            #print str(i)+' '+str(j)
            s = eval(n[:i+1]+'('+n[i+1:j]+')'+n[j:])
            ans = max(ans,s)
for j in a:
    for i in a:
        if j>i:
            #print n[:i]+'('+n[i:j]+')'+n[j:]
            s = eval(n[:i+1]+'('+n[i+1:j]+')'+n[j:])
            ans = max(ans,s)
ans = max(ans,eval(n))
print ans


n = raw_input()
ans = 0
a = []
for i in xrange(len(n)):
    if n[i]=='*':
        a.append(i)
for i in a:
    for j in xrange(i+3,len(n)+1):
        if j==len(n) or n[j]=='*' or n[j] == '+':
           #print n[:i+1]+'('+n[i+1:j]+')'+n[j:]
            #print str(i)+' '+str(j)
            s = eval(n[:i+1]+'('+n[i+1:j]+')'+n[j:])
            ans = max(ans,s)
for j in a:
    for i in xrange(j-2):
        if n[i] in '0123456789':
            #print n[:i]+'('+n[i:j]+')'+n[j:]
            s = eval(n[:i*2]+'('+n[i*2:j*2-1]+')'+n[j*2-1:])
            ans = max(ans,s)
ans = max(ans,eval(n))
print ansn = raw_input()
ans = 0
a = []
for i in xrange(len(n)):
    if n[i]=='*':
        a.append(i)
for i in a:
    for j in xrange(i+3,len(n)+1):
        if j==len(n) or n[j]=='*' or n[j] == '+':
           #print n[:i+1]+'('+n[i+1:j]+')'+n[j:]
            #print str(i)+' '+str(j)
            s = eval(n[:i+1]+'('+n[i+1:j]+')'+n[j:])
            ans = max(ans,s)
for j in a:
    for i in xrange(j-2):
        if n[i] in '0123456789':
            #print n[:i]+'('+n[i:j]+')'+n[j:]
            s = eval(n[:i*2]+'('+n[i*2:j*2-1]+')'+n[j*2-1:])
            ans = max(ans,s)
ans = max(ans,eval(n))
print ans


n = raw_input()
ans = 0
for i in xrange(len(n)/2):
    for j in xrange(i+1,len(n)/2+2):
        s = eval(n[:i*2]+'('+n[i*2:j*2-1]+')'+n[j*2-1:])
        ans = max(ans,s)
print ans


n = raw_input()
ans = 0
a = []
for i in xrange(len(n)):
    if n[i]=='*':
        a.append(i)
for i in a:
    for j in xrange(i+3,len(n)+1):
        if j%2!=0:
           #print n[:i+1]+'('+n[i+1:j]+')'+n[j:]
            #print str(i)+' '+str(j)
            s = eval(n[:i+1]+'('+n[i+1:j]+')'+n[j:])
            ans = max(ans,s)
for j in a:
    for i in xrange(j-2):
        if i%2==0:
            #print n[:i]+'('+n[i:j]+')'+n[j:]
            s = eval(n[:i]+'('+n[i:j]+')'+n[j:])
            ans = max(ans,s)
ans = max(ans,eval(n))
print ans


n = raw_input()
ans = 0
a = []
for i in xrange(len(n)):
    if n[i]=='*':
        a.append(i)
for i in a:
    for j in xrange(i+3,len(n)+1):
        if j==len(n) or n[j]=='*' or n[j] == '+':
           #print n[:i+1]+'('+n[i+1:j]+')'+n[j:]
            #print str(i)+' '+str(j)
            s = eval(n[:i+1]+'('+n[i+1:j]+')'+n[j:])
            ans = max(ans,s)
for j in a:
    for i in xrange(j-2):
        if n[i] in '0123456789':
            #print n[:i]+'('+n[i:j]+')'+n[j:]
            s = eval(n[:i*2]+'('+n[i*2:j*2-1]+')'+n[j*2-1:])
            ans = max(ans,s)
ans = max(ans,eval(n))
print ans


n = raw_input()
ans = 0
a = [-1]
for i in xrange(len(n)):
    if n[i]=='*':a.append(i)
a.append(len(n))
for i in a:
    for j in a:
        if j>i:
            ans = max(ans,eval(n[:i+1]+'('+n[i+1:j]+')'+n[j:]))
ans = max(ans,eval(n))
print ans


n = raw_input()
#n = '2*'*15+'1+'*400+'5'
ans = 0
a = [-1]
for i in xrange(len(n)):
    if n[i]=='*':
        a.append(i)
        a.append(len(n))
for i in a:
    for j in a:
        if j>i:
           #print n[:i+1]+'('+n[i+1:j]+')'+n[j:]
            #print str(i)+' '+str(j)
            s = eval(n[:i+1]+'('+n[i+1:j]+')'+n[j:])
            ans = max(ans,s)
for j in a:
    for i in a:
        if j>i:
            #print n[:i]+'('+n[i:j]+')'+n[j:]
            s = eval(n[:i+1]+'('+n[i+1:j]+')'+n[j:])
            ans = max(ans,s)
ans = max(ans,eval(n))
print ans
#sdgsdgsdgsdg


exp = '1*' + raw_input() + '*1'
n = len(exp)
ans = eval(exp)

for i in range(n) :
    if exp[i] == '*' :
        for j in range(i + 1, n) :
            if exp[j] == '*' :
                delta = eval(exp[:i + 1] + '(' + exp[i + 1 : j] + ')' + exp[j:])
                ans = max(ans, delta)
print ans


exp = raw_input()
n = len(exp)
ans = eval(exp)

for i in range(n) :
    if exp[i] == '*' :
        for j in range(i + 1, n) :
            if exp[j] == '*' :
                delta = eval(exp[:i + 1] + '(' + exp[i + 1 : j] + ')' + exp[j:])
                ans = max(ans, delta)
print ans


s=raw_input()
m=eval(s)
ms=[]
s='1*'+s+'*1'
for i in range(len(s)):
	if s[i]=='*':
		ms.append(i)
for i in range(len(ms)-1):
    for j in range(i+1,len(ms)):
            t=s[:ms[i]+1]+'('+s[ms[i]+1:ms[j]]+')'+s[ms[j]:]
            print t
            if eval(t)>m:
                m=eval(t)
print m


s=raw_input()
m=eval(s)
ms=[]
s='1*'+s+'*1'
for i in range(len(s)):
	if s[i]=='*':
		ms.append(i)
for i in range(len(ms)-1):
    for j in range(i+1,len(ms)):
            t=s[:ms[i]+1]+'('+s[ms[i]+1:ms[j]]+')'+s[ms[j]:]
            #print t
            if eval(t)>m:
                m=eval(t)
print m


e = raw_input()
n, result = len(e), eval(e)
for i in xrange (-1, n):
    if i == -1 or e[i] == '*':
        for j in xrange (i+1, n+1):
            if j == n or e[j] == '*':
                result = max(result, eval(e[i+1] + '(' + e[i+1:j] + ')' + e[j:]))
print(result)


e = raw_input()

n, result = len(e), eval(e)
for i in xrange (-1, n):
    if i == -1 or e[i] == '*':
        for j in xrange (i+1, n+1):
            if j == n or e[j] == '*':
            result = max(result, eval(e[:i+1] + '(' + e[i+1:j] + ')' + e[j:]))
print(result)


e = raw_input()
n, result = len(e), eval(e)
for i in xrange (-1, n):
    if i == -1 or e[i] == '*'
    for j in xrange (i+1, n+1):
        if j == n or e[j] == '*':
            result = max(result, eval(e[:i+1] + '(' + e[i+1:j] + ')' + e[j:]))
print(result)


e = raw_input()

n, ans = len(e), eval(e)

for i in xrange(-1, n):
    if i == -1 or e[i] == '*':
        for j in xrange(i + 1, n + 1):
            if j == n or e[j] == '*':
                ans = max(ans, eval(e[:i + 1] + '(' +  e[i + 1: j] + ')' + e[j:]))
print(ans)


e = raw_input()
n, result = len(e), eval(e)
for i in xrange (-1, n):
    if i == -1 or e[i] == '*':
        for j in xrange (i+1, n+1):
            if j == n or e[j] == '*':
                result = max(result, eval(e[:i+1] + '(' + e[i+1:j] + ')' + e[j:]))
print(result)


e = raw_input()
n, result = len(e), eval(e)
for i in xrange (-1, n):
    if i == -1 or e[i] == '*'
    for j in xrange (i+1, n+1):
        if j == n or e[j] == '*':
            result = max(result, eval(e[i+1] + '(' + e[i+1:j] + ')' + e[j:]))
print(result)


e = raw_input()
n, result = len(e), eval(e)
for i in xrange (-1, n):
    if i == -1 or e[i] == '*':
        for j in xrange (i+1, n+1):
            if j == n or e[j] == '*':
                result = max(result, eval(e[i+1] + '(' + e[i+1:j] + ')' + e[j:]))
print(res)


e = raw_input()

n, ans = len(e), eval(e)

for i in xrange(-1, n):
    if i == -1 or e[i] == '*':
                       for j in xrange(i + 1, n + 1):
            if j == n or e[j] == '*':
                ans = max(ans, eval(e[:i + 1] + '(' +  e[i + 1: j] + ')' + e[j:]))
print(ans)


e = raw_input()
n, result = len(e), eval(e)
for i in xrange (-1, n):
    if i == -1 or e[i] == '*':
    for j in xrange (i+1, n+1):
        if j == n or e[j] == '*':
            result = max(result, eval(e[:i+1] + '(' + e[i+1:j] + ')' + e[j:]))
print(result)


s = raw_input()

m = eval(s)
n = len(s)
l = []
for i in xrange(1, n, 2):
	if s[i] == '*':
		l.append(i)

if len(l) != 0:
	for i in xrange(len(l)):
		for j in xrange(i, len(l), 1):
			ss = ""
			ii = l[i]
			jj = l[j]

			ss += s[:(ii+1)]
			ss += '('
			ss += s[(ii+1):(jj)]
			ss += ')'
			ss += s[(jj):]

			m = max(m, eval(ss))

	ss = "("
	ss += s[:l[0]]
	ss += ')'
	ss += s[l[0]:]

	m = max(m, eval(ss))

	ss = ""
	ss += s[:(l[len(l)-1] + 1)]
	ss += '('
	ss += s[(l[len(l)-1] + 1):]
	ss += ')'

	m = max(m, eval(ss))

print m


s = raw_input()

m = eval(s)
n = len(s)
l = []
for i in xrange(1, n, 2):
	if s[i] == '*':
		l.append(i)

if len(l) != 0:
	for i in xrange(len(l)):
		for j in xrange(i+1, len(l), 1):
			ss = ""
			ii = l[i]
			jj = l[j]

			ss += s[:(ii+1)]
			ss += '('
			ss += s[(ii+1):(jj)]
			ss += ')'
			ss += s[(jj):]

			m = max(m, eval(ss))

	ss = "("
	ss += s[:l[0]]
	ss += ')'
	ss += s[l[0]:]

	m = max(m, eval(ss))

	ss = ""
	ss += s[:(l[len(l)-1] + 1)]
	ss += '('
	ss += s[(l[len(l)-1] + 1):]
	ss += ')'

	m = max(m, eval(ss))

print m


s = raw_input()
d = [-1]
for i in xrange(len(s)):
    if s[i] == '*':
        d.append(i)
d.append(len(s))
mx = eval(s)
for i in xrange(len(d) - 1):
    for j in xrange(i + 1, len(d)):
        inside = eval(s[d[i] + 1: d[j]])
        mx = max(mx, eval(s[: d[i] + 1] + str(inside) + s[d[j]:]))
print mx


s = raw_input()

m = eval(s)
n = len(s)
l = []
for i in xrange(1, n, 2):
	if s[i] == '*':
		l.append(i)

if len(l) != 0:
	for i in xrange(len(l)):
		for j in xrange(i + 1, len(l), 1):
			ss = ""
			ii = l[i]
			jj = l[j]

			ss += s[:(ii+1)]
			ss += '('
			ss += s[(ii+1):(jj)]
			ss += ')'
			ss += s[(jj):]

			m = max(m, eval(ss))

	ss = "("
	ss += s[:l[0]]
	ss += ')'
	ss += s[l[0]:]

	m = max(m, eval(ss))

	ss = ""
	ss += s[:(l[len(l)-1] + 1)]
	ss += '('
	ss += s[(l[len(l)-1] + 1):]
	ss += ')'

	m = max(m, eval(ss))

print m


s = raw_input()

m = eval(s)
n = len(s)
l = []
for i in xrange(1, n, 2):
	if s[i] == '*':
		l.append(i)

if len(l) != 0:
	for i in xrange(len(l)):
		for j in xrange(i + 1, len(l), 1):
			ss = ""
			ii = l[i]
			jj = l[j]

			ss += s[:(ii+1)]
			ss += '('
			ss += s[(ii+1):(jj)]
			ss += ')'
			ss += s[(jj):]

			m = max(m, eval(ss))

	ss = "("
	ss += s[:l[0]]
	ss += ')'
	ss += s[l[0]:]

	m = max(m, eval(ss))

	ss = ""
	ss += s[:(l[0] + 1)]
	ss += '('
	ss += s[(l[0] + 1):]
	ss += ')'

	m = max(m, eval(ss))

print m


a = raw_input()
ans = eval(a)

def add_parens(s, l, r):
	return s[:l] + '(' + s[l:r] + ')' + s[r:]

for i in xrange(0,len(a)):
	if a[i] != '*':
		continue
	ans = max(ans, eval(add_parens(a, 0, i)))
	ans = max(ans, eval(add_parens(a,i+1, len(a))))

for i in xrange(0,len(a)):
	if a[i] != '*':
		continue
	for j in xrange(i+1,len(a)):
		if a[j] != '*':
			continue
		ans = max(ans, eval(add_parens(a, i+1, j)))

print ans


a="1*"+raw_input()+"*1"
ans=eval(a)
for i in xrange(len(a)):
	if a[i]=='*':
		for j in xrange(i+1,len(a)):
			if a[j]=='*':
				ans=max(ans,eval(s[:i+1]+'('+s[i+1:j]+')'+s[j:]))
print ans


a="1*"+raw_input()+"*1"
ans=eval(a)
for i in xrange(len(a)):
	if a[i]=='*':
		for j in xrange(i+1,len(a)):
			if a[j]=='*':
				ans=max(ans,eval(a[:i+1]+'('+a[i+1:j]+')'+a[j:]))
print ans


r = "1*" + raw_input() + "*1"

def evaluate(x):
    l = len(x)
    y = []
    i = 0
    while True:
        if i >= l:
            break
        if x[i] == '*':
            j = y.pop()
            y.append(j*x[i+1])
            i += 1
        elif x[i] != '+':
            y.append(x[i])
        i += 1

    return sum(y)

r = [i if i in ['*', '+'] else int(i) for i in r]
b = []
[b.append(i) for i in xrange(len(r)) if r[i] == '*']

res = evaluate(r)
for i in xrange(len(b)):
    j = i+1
    while True:
        if j >= len(b):
            break
        x = evaluate(r[b[i]+1:b[j]])
        m = evaluate(r[:b[i]+1] + [x] + r[b[j]:])
        res = max(m, res)
        j += 1

print res


S=raw_input()
prec=-1
sol=eval(S)

for i in range(0,len(S),2):
	for j in range(i+2,len(S),2):
		sol=max(sol,eval(S[:i] + "(" + S[i:j+1] + ")" + S[j+1:]))
print sol


S="1*" +  raw_input() + "*1"
prec=-1
sol=eval(S)

for i in range(2,len(S)-2,2):
	if(S[i-1]!='*'):continue
	for j in range(i+2,len(S)-2,2):
		if(S[j+1]!='*'):  continue
		sol=max(sol,eval(S[:i] + "(" + S[i:j+1] + ")" + S[j+1:]))
print sol


str=raw_input()
ans = 0
s = '1*'+str+'*1'
l = len(s)
for i in range(1, l-2, 2):
    if s[i]!='*':
        continue
    for j in range(i+2, l, 2):
        if s[j]!='*':
            continue
        k = s[:i+1]+'('+s[i+1:j]+')'+s[j:]
        ans = max(ans, eval(k))
print ans


str=raw_input()
l = len(str)
ans = 0
for i in range(0, l-2, 2):
    for j in range(i+3, l, 2):
        s=str[:i]+'('+str[i:j]+')'+str[j:]
        ans = max(ans, eval(s))
print ans


import re

s = raw_input().strip()

if s.count('+') == 1:
	p = s.index('+')
	s = s[:p-1] + '(' + s[p-1:p+2] + ')' + s[p+2:]
	print(eval(s))
else:
	best = eval(s)
	s = '*' + s
	reg1 = re.compile(r'\*\d\+')
	reg2 = re.compile(r'\+\d\*')
	for m1 in reg1.finditer(s):
		p1 = m1.start()
		for m2 in reg2.finditer(s[m1.start():]):
			p2 = m2.start()
			s1 = s[:p1+1] + '(' + s[p1+1:p1+p2+2] + ')' + s[p1+p2+2:]
			v1 = eval(s1[1:])
			if v1 > best:
				best = v1
	print best


import re

s = raw_input().strip()

if s.count('+') == 1:
	p = s.index('+')
	s = s[:p-1] + '(' + s[p-1:p+2] + ')' + s[p+2:]
	print(eval(s))
else:
	best = eval(s)
	s = '*' + s + '*'
	reg1 = re.compile(r'\*\d\+')
	reg2 = re.compile(r'\+\d\*')
	for m1 in reg1.finditer(s):
		p1 = m1.start()
		for m2 in reg2.finditer(s[m1.start():]):
			p2 = m2.start()
			s1 = s[:p1+1] + '(' + s[p1+1:p1+p2+2] + ')' + s[p1+p2+2:]
			v1 = eval(s1[1:-1])
			if v1 > best:
				best = v1
	print best


__author__ = 'yesh233'

def gao2(x, y, l, r):
    y *= a[l]
    for i in range(l, r):
        if e[i] == '*':
            y *= a[i + 1]
        else:
            x, y = x + y, a[i + 1]
    return x, y

def gao(l, r):
    lx, ly = gao2(0, 1, 0, l)
    cx, cy = gao2(0, 1, l + 1, r)
    rx, ry = lx, ly * (cx + cy)
    return sum(gao2(rx, ry, r + 1, len(a)-1))

s = raw_input()
s = '1*'+s+'*1'
# print s
e = [s[i] for i in range(1, len(s), 2)]
a = [int(s[i]) for i in range(0, len(s), 2)]
pe = filter(lambda i: e[i] == '*', range(len(e)))
ans = max([gao(pe[i], pe[j]) for j in range(len(pe)) for i in range(j)])
print ans


import sys

str = raw_input()
print eval(str)


import sys

s = raw_input()
l = len(s)/2
ll = len(s)
ans=eval(s)
pre = []
for i in range(ll):
	if i%2==1 and s[i]=='*':
		pre.append(i)
for x in pre:
	for y in range(l):
		lo = y*2
		if lo<x:
			cnt = eval(s[:lo]+"("+s[lo:x]+")"+s[x:])
			if cnt>ans:
				ans=cnt;
		else:
			break
print ans


import sys

s = raw_input()
l = len(s)/2
ll = len(s)
ans=0
s1=""
for i in range(l):
	lo1=2*i
	if lo1>0:
		s1=s1+s[lo1-2]+s[lo1-1]
	s2=s[lo1]
	s3=s[lo1+1:ll]
	for j in range(i+1,l):
		lo2=2*j
		s2=s2+s[lo2-1]+s[lo2]
		s3=s3[2:]
		cnt = eval(s1+"("+s2+")"+s3)
		if (cnt>ans):
			ans=cnt
print ans


import sys

s = raw_input()
l = len(s)/2
ll = len(s)
ans=0
pre = []
for i in range(ll):
	if i%2==1 and s[i]=='*':
		pre.append(i)
for x in pre:
	for y in range(l):
		lo = y*2
		if lo<x:
			cnt = eval(s[:lo]+"("+s[lo:x]+")"+s[x:])
			if cnt>ans:
				ans=cnt;
		else:
			break
print ans


import sys

s = raw_input()
l = len(s)/2
ll = len(s)
ans=eval(s)
pre = [-1]
for i in range(ll+1):
    if i%2==1 and s[i]=='*' or i==ll:
		for x in pre:
			cnt = eval(s[:x+1]+"("+s[x+1:i]+")"+s[i:])
			if cnt>ans:
				ans=cnt;
		pre.append(i)
print ans


s = raw_input()
ll = len(s)
ans=eval(s)
pre = [-1]
for i in range(ll+1):
    if i==ll or i%2==1 and s[i]=='*':
		for x in pre:
			cnt = eval(s[:x+1]+"("+s[x+1:i]+")"+s[i:])
			ans=max(ans,cnt);
		pre.append(i)
print ans


import sys

s = raw_input()
l = len(s)/2
ll = len(s)
ans=0

pre = -1
for i in range(ll):
	if i%2==1 and s[i]=='*':
		if pre==-1:
			cnt = eval("("+s[:i]+")"+s[i:])
			if cnt>ans:
				ans=cnt;
			pre=i
		else:
			#print s[:pre+1]+"("+s[pre+1:i]+")"+s[i:]
			cnt = eval(s[:pre+1]+"("+s[pre+1:i]+")"+s[i:])
			if cnt>ans:
				ans=cnt;
			pre=i;
print ans


import sys

s = raw_input()
l = len(s)/2
ll = len(s)
ans=0

pre = []
for i in range(ll):
	if i%2==1 and s[i]=='*':
		if len(pre)==0:
			cnt = eval("("+s[:i]+")"+s[i:])
			if cnt>ans:
				ans=cnt;
			pre.append(i)
		else:
			#print s[:pre+1]+"("+s[pre+1:i]+")"+s[i:]
			for x in pre:
				cnt = eval(s[:x+1]+"("+s[x+1:i]+")"+s[i:])
				if cnt>ans:
					ans=cnt;
			pre.append(i)
			#pre=i;
print ans


import sys

s = raw_input()
l = len(s)/2
ll = len(s)
ans=eval(s)
pre = [-1]
for i in range(ll):
    if i%2==1 and s[i]=='*':
        if len(pre)==0:
            cnt = eval("("+s[:i]+")"+s[i:])
            if cnt>ans:
                ans=cnt;
            pre.append(i)
        else:
            #print s[:pre+1]+"("+s[pre+1:i]+")"+s[i:]
            for x in pre:
                cnt = eval(s[:x+1]+"("+s[x+1:i]+")"+s[i:])
                if cnt>ans:
                    ans=cnt;
            pre.append(i)
            #pre=i;
print ans


import sys

s = raw_input()
l = len(s)/2
ll = len(s)
ans=0

pre = -1
for i in range(ll):
	if i%2==1 and s[i]=='*':
		if pre==-1:
			cnt = eval("("+s[:i]+")"+s[i:])
			if cnt>ans:
				ans=cnt;
			pre=i
		else:
			#print s[:pre+1]+"("+s[pre+1:i]+")"+s[i:]
			cnt = eval(s[:pre+1]+"("+s[pre+1:i]+")"+s[i:])
			if cnt>ans:
				ans=cnt;
			#pre=i;
print ans


import sys

s = raw_input()
l = len(s)/2
ll = len(s)
ans=eval(s)
pre = [-1]
for i in range(ll+1):
    if i==ll or i%2==1 and s[i]=='*':
		for x in pre:
			cnt = eval(s[:x+1]+"("+s[x+1:i]+")"+s[i:])
			if cnt>ans:
				ans=cnt;
		pre.append(i)
print ans


import sys

s = raw_input()
l = len(s)/2
ll = len(s)
ans=0
for i in range(l):
	for j in range(i+1,l):
		lo1=2*i
		lo2=2*j
		#print lo1,lo2
		if lo1>0:
			s1=s[0:lo1]
		else:
			s1=""
		s2="("+s[lo1:lo2+1]+")"
		if lo2<ll-1:
			s3=s[lo2+1:ll]
		else:
			s3=""
		#print s1,s2,s3
		cnt = eval(s1+s2+s3)
		if (cnt>ans):
			ans=cnt
print ans


import sys

s = raw_input()
l = len(s)/2
ll = len(s)
ans=0
pre = [-1]
for i in range(ll):
	if i%2==1 and s[i]=='*':
		if len(pre)==0:
			cnt = eval("("+s[:i]+")"+s[i:])
			if cnt>ans:
				ans=cnt;
			pre.append(i)
		else:
			#print s[:pre+1]+"("+s[pre+1:i]+")"+s[i:]
			for x in pre:
				cnt = eval(s[:x+1]+"("+s[x+1:i]+")"+s[i:])
				if cnt>ans:
					ans=cnt;
			pre.append(i)
			#pre=i;
print ans


s = raw_input()
s = "1*" + s + "*1"
ret = eval(s)
mult = []
for i in xrange(len(s)):
    if s[i] == '*':
        mult.append(i)
for i in xrange(len(mult)):
    for j in xrange(i + 1,len(mult)):
        tmp = eval(s[mult[i] + 1:mult[j]])
        ret = max(ret,eval(s[:mult[i] + 1] + str(tmp) + s[mult[j]:]))
print ret


s = raw_input()
n = len(s)
ans = eval(s)
p = [-1]
for i in range(n + 1):
    if i == n or i % 2 == 1 and s[i] == '*':
        for x in p:
            ans = max(ans, eval(s[:x+1] + '(' + s[x+1:i] + ')' + s[i:]))
        p.append(i)

print(ans)


x = raw_input()
x = "1*"+x+"*1"
z = []
for i in range(len(x)):
    if x[i] == '*':
        z.append(i)
p = 0
for i in range(len(z)):
    a = z[i]
    for j in range(i+1,len(z)):
        b = z[j]
        u = x[:a+1] + "(" + x[a+1:b] + ")" + x[b:]
        p = max(p,eval(u))
print p


s=raw_input()
ans=eval(s)
l=len(s)
for i in xrange(-1,l-1):
    if i==-1 or s[i]=='*':
        for j in xrange(i+1,l+1):
            if j==l or s[j]=='*':
                ans=max(ans,eval(s[:i+1]+'('+s[i+1:j]+')'+s[j:]))
print ans


tmp = raw_input().split('+')
tlen = len(tmp)
newstr = []
z = 0
while(z < tlen):
	if(len(tmp[z])==1):
		tempans = 0
		while(z < tlen and len(tmp[z])==1):
			tempans += int(tmp[z])
			z += 1
		newstr.append(str(tempans))
	else:
		newstr.append(tmp[z])
		z += 1

original = "+".join(newstr)
orlen = len(original)
fanswer = -1

# print original

for x in xrange(0,orlen):
	if(x != 0):
		if(original[x-1] not in ['+','*']):
			continue
	for y in xrange(x,orlen):
		if(y != orlen-1):
			if(original[y+1] not in ['+','*']):
				continue
		toprocess = original[x:y+1].split('+')
		answer = 0
		for z in toprocess:
			answer += reduce(lambda i,j: i*j,map(int,z.split('*')))
		toprocess = (original[0:x]+str(answer)+original[y+1:]).split('+')
		answer = 0
		for z in toprocess:
			answer += reduce(lambda i,j: i*j,map(int,z.split('*')))
		if(answer > fanswer):
			fanswer = answer

print fanswer


original = raw_input()
orlen = len(original)
fanswer = -1

for x in xrange(0,orlen,2):
	for y in xrange(x,orlen,2):
		toprocess = original[x:y+1].split('+')
		answer = 0
		for z in toprocess:
			answer += reduce(lambda i,j: i*j,map(int,z.split('*')))
		toprocess = (original[0:x]+str(answer)+original[y+1:]).split('+')
		answer = 0
		for z in toprocess:
			answer += reduce(lambda i,j: i*j,map(int,z.split('*')))
		if(answer > fanswer):
			fanswer = answer

print fanswer


original = raw_input()
orlen = len(original)
fanswer = -1

for x in xrange(0,orlen,2):
	for y in xrange(x,orlen,2):
		# # temp = original[x:y+1].split('+')
		# toprocess = ' '
		# # print original[0:x]+'('+original[x:y+1]+')'+original[y+1:]
		one = original[0:x]
		two = original[x:y+1]
		three = original[y+1:]
		toprocess = two.split('+')
		answer = 0
		for z in toprocess:
			answer += reduce(lambda i,j: i*j,map(int,z.split('*')))
		newstring = one+str(answer)+three
		toprocess = newstring.split('+')
		answer = 0
		for z in toprocess:
			answer += reduce(lambda i,j: i*j,map(int,z.split('*')))
		if(answer > fanswer):
			fanswer = answer

print fanswer


original = raw_input()
orlen = len(original)
fanswer = -1

for x in xrange(0,orlen,2):
	for y in xrange(x,orlen,2):
		answer = eval(original[x:y+1])
		answer = eval(original[0:x]+'('+str(answer)+')'+original[y+1:])
		if(answer > fanswer):
			fanswer = answer

print fanswer


tmp = raw_input().split('+')
tlen = len(tmp)
newstr = []
z = 0
while(z < tlen):
	if(len(tmp[z])==1):
		tempans = 0
		while(z < tlen and len(tmp[z])==1):
			tempans += int(tmp[z])
			z += 1
		newstr.append(str(tempans))
	else:
		newstr.append(tmp[z])
		z += 1

original = "+".join(newstr)
orlen = len(original)
fanswer = -1

for x in xrange(0,orlen):
	if(x != 0):
		if(original[x-1] not in ['+','*']):
			continue
	for y in xrange(x,orlen):
		if(y != orlen-1):
			if(original[y+1] not in ['+','*']):
				continue
		answer = eval(original[0:x]+'('+str(eval(original[x:y+1]))+')'+original[y+1:])
		if(answer > fanswer):
			fanswer = answer

print fanswer


tmp = raw_input().split('+')
tlen = len(tmp)
newstr = []
z = 0
while(z < tlen):
	if(len(tmp[z])==1):
		tempans = 0
		while(z < tlen and len(tmp[z])==1):
			tempans += int(tmp[z])
			z += 1
		newstr.append(str(tempans))
	else:
		newstr.append(tmp[z])
		z += 1

original = "+".join(newstr)
orlen = len(original)
fanswer = -1

# print original

for x in xrange(0,orlen):
	if(x != 0):
		if(original[x-1] not in ['+','*']):
			continue
	for y in xrange(x,orlen):
		if(y != orlen-1):
			if(original[y+1] not in ['+','*']):
				continue
		# print original[0:x]+'('+original[x:y+1]+')'+original[y+1:]
		# answer = eval(original[x:y+1])
		answer = eval(original[0:x]+'('+str(eval(original[x:y+1]))+')'+original[y+1:])
		if(answer > fanswer):
			fanswer = answer

print fanswer


tmp = raw_input().split('+')
tlen = len(tmp)
newstr = []
z = 0
while(z < tlen):
	if(len(tmp[z])==1):
		tempans = 0
		while(len(tmp[z])==1):
			tempans += int(tmp[z])
			z += 1
		newstr.append(str(tempans))
	else:
		newstr.append(tmp[z])
		z += 1

original = "+".join(newstr)
orlen = len(original)
fanswer = -1

# print original

for x in xrange(0,orlen):
	if(x != 0):
		if(original[x-1] not in ['+','*']):
			continue
	for y in xrange(x,orlen):
		if(y != orlen-1):
			if(original[y+1] not in ['+','*']):
				continue
		# print original[0:x]+'('+original[x:y+1]+')'+original[y+1:]
		# answer = eval(original[x:y+1])
		answer = eval(original[0:x]+'('+str(eval(original[x:y+1]))+')'+original[y+1:])
		if(answer > fanswer):
			fanswer = answer

print fanswer


e = raw_input()

n, result = len(e), eval(e)
for i in xrange(-1, n):
    if i == -1 or e[i] == '*':
        for j in xrange(i + 1, n + 1):
            if j == n or e[j] == '*':
                result = max(result, eval(e[:i + 1] + '(' + e[i + 1:j] + ')' + e[j:]))
print(result)


'''

   			 ||Sri:||

                      __|
 ______________|_________________________
      |    |   ___|    |    |    ___|      |      |    |___
 /\  /\    |   |___    |    |   |___|      |      |    |___|
/  \/  \   |   ___|    |    |         |_/    |___|    |___

I am a beginner. Feel free to send tutorials/help to srinivasan1995@gmail.com.

Codeforces, SPOJ handle: desikachariar.
Hackerrank, Codechef handle: Prof_Calculus.

Advices/Help are welcome. You will definitely get a thanks in return. Comments to be avoided.

College: International Institute of Information Technology, Bangalore.

'''

import math

def fn(s):
	s = s.split('+')
	for i in range(len(s)):
		q = s[i].split('*')
		a = 1
		for k in q:
			a = a*int(k)
		s[i]=a
	p=0
	for i in s:
		p+=int(i)
	return p

x = "1*" + raw_input() + "*1"
v=[]
for i in range(len(x)):
	if x[i] == '*':
		v += [i]
ans = 0
for i in range(len(v)-1):
	for j in range(i+1, len(v)):
		t = fn( x[:v[i]] + "*" +  str(fn(x[v[i]+1 : v[j]])) + x[v[j]:])
		ans = max(ans, t)
print ans


def main():
    s = raw_input()
    t = []
    t.append(-1)
    for i, p in enumerate(s):
        if p == '*':
            t.append(i)
    t.append(len(s))
    res = eval(s)
    for i in xrange(len(t)):
        for j in xrange(i + 1, len(t)):
            x, y = t[i], t[j]
            ns = s[:x + 1] + '(' + s[x + 1:y] + ')' + s[y:]
            res = max(res, eval(ns))
    print res

if __name__ == '__main__':
    main()


s = str(input())
res = eval(s)
n = len(s)
for i in range(-1, n):
    if i == -1 or s[i] == '*':
        for j in range(i + 1, n + 1):
            if j == n or s[j] == '*':
                new_s = s[0:i + 1] + "(" + s[i + 1:j] + ")" + s[j:n]
                res = max(res, eval(new_s))
print res


s = str(raw_input())
res = eval(s)
n = len(s)
# for i in range(-1, n):
# 	if i == -1 or s[i] == '*':
# 		for j in range(i + 1, n + 1):
# 			if j == n or s[j] == '*':
# 				new_s = s[0:i + 1] + "(" + s[i + 1:j] + ")" + s[j:n]
# 				res = max(res, eval(new_s))

for i in range(-1, n):
	for j in range(i + 1, n + 1):
		new_s = s[0:i + 1] + "(" + s[i + 1:j] + ")" + s[j:n]
		try:
			res = max(res, eval(new_s))
		except:
			pass

print res


s = input()
res = eval(s)
n = len(s)
for i in range(-1, n):
    if i == -1 or s[i] == '*':
        for j in range(i + 1, n + 1):
            if j == n or s[j] == '*':
                new_s = s[0:i + 1] + "(" + s[i + 1:j] + ")" + s[j:n]
                res = max(res, eval(new_s))
print res


s = str(raw_input())
res = eval(s)
n = len(s)
for i in range(-1, n):
	if i == -1 or s[i] == '*':
		for j in range(i + 1, n + 1):
			if j == n or s[j] == '*':
				new_s = s[0:i + 1] + "(" + s[i + 1:j] + ")" + s[j:n]
				res = max(res, eval(new_s))
print res


s = str(input())
res = eval(s)
n = len(s)
for i in range(-1, n):
	if i == -1 or s[i] == '*':
		for j in range(i + 1, n + 1):
			if j == n or s[j] == '*':
				new_s = s[0:i + 1] + "(" + s[i + 1:j] + ")" + s[j:n]
				res = max(res, eval(new_s))
print res


s = str(raw_input())
res = eval(s)
n = len(s)
for i in range(-1, n):
	if i == -1 or s[i] == '*':
		for j in range(i + 1, n + 1):
			if j == n or s[j] == '*':
				new_s = s[0:i + 1] + "(" + s[i + 1:j] + ")" + s[j:n]
				res = max(res, eval(new_s))

print res


s = input()
res = eval(s)
n = len(s)
for i in range(-1, n):
    if i == -1 or s[i] == '*':
        for j in range(i + 1, n + 1):
            if j == n or s[j] == '*':
                new_s = s[0:i + 1] + "(" + s[i + 1:j] + ")" + s[j:n]
                res = max(res, eval(new_s))
print(res)


x = raw_input()
x = "1*"+x+"*1"
z = []
for i in range(len(x)):
    if x[i] == '*':
        z.append(i)
p = 0
for i in range(len(z)):
    a = z[i]
    for j in range(i+1,len(z)):
        b = z[j]
        u = x[:a+1] + "(" + x[a+1:b] + ")" + x[b:]
        p = max(p,eval(u))
print p


a = [[1]] + [map(int, a.split('+')) for a in raw_input().split('*')] + [[1]]
n = len(a) - 2
m = 0
for i in xrange(1,n+1):
    for j in xrange(i, n+1):
        s = 0
        for k in xrange(i-2):
            s += sum(a[k])
        s += sum(a[i-1][:-1])
        left = a[i-1][-1]
        s1 = sum(sum(x) for x in a[i:j+1])
        right = a[j+1][0]
        s += s1*left*right
        s += sum(a[j+1][1:])
        for k in xrange(j + 2, n + 1):
            s += sum(a[k])
        if s > m:
            m = s
print m


import sys, os

def solve():
    s = raw_input()
    res = eval(s)
    for l in xrange(-1, len(s)):
        if s[l] == '*' or l == -1:
            for r in xrange(l + 2, len(s) + 1, 2):
                if r == len(s) or s[r] == '*':
                    temp = s[:l + 1] + '(' + s[l + 1 : r] + ')' + s[r : ]
                    try: res = max(res, eval(temp))
                    except: pass
    print(res)

# def prt(l): return print(' '.join(l))
# def rv(): return map(int, input().split())
# def rl(n): return [list(map(int, input().split())) for _ in range(n)]
if os.path.exists("test.txt"): sys.stdin = open("test.txt")
solve()


str = '1*' + raw_input() + '*1'
l = len(str)
ans = 0
for i in range(2, l, 2):
    if (str[i - 1] == '*'):
        for j in range(i + 1, l, 2):
            if str[j] == '*':
                ans = max(ans, eval(str[:i] + '(' + str[i:j] + ')' + str[j:]))
print(ans)


str = '1*' + input() + '*1'
l = len(str)
ans = 0
for i in range(2, l, 2):
    if (str[i - 1] == '*'):
        for j in range(i + 1, l, 2):
            if str[j] == '*':
                ans = max(ans, eval(str[:i] + '(' + str[i:j] + ')' + str[j:]))
print(ans)


from __future__ import division
from __future__ import print_function

input = raw_input

def main():
    # from ast import literal_eval
    a = input()
    val = eval(a)

    for i in range(1, len(a), 2):
        if a[i] == '*':
            val = max(val, eval('(' + a[:i] + ')' + a[i:]))
            val = max(val, eval(a[:i+1] + '(' + a[i + 1:] + ')'))

            for j in range(i + 2, len(a), 2):
                if a[j] == '*':
                    val = max(val, eval(a[: i + 1] + '(' + a[ i + 1: j] + ')' + a[j:]));
    print(val)

if __name__ == '__main__':
    main()


exp= raw_input()
n, result = len(exp), eval(exp)
for i in xrange(-1, n):
    if i == -1 or e[i] == '*':
        for j in xrange(i + 1, n + 1):
            if j == n or e[j] == '*':
                result = max(result, eval(e[:i + 1] + '(' + e[i + 1:j] + ')' + e[j:]))
print(result)


e = raw_input()

n, result = len(e), eval(e)
for i in xrange(-1, n):
    if i == -1 or e[i] == '*':
        for j in xrange(i + 1, n + 1):
            if j == n or e[j] == '*':
                result = max(result, eval(e[:i + 1] + '(' + e[i + 1:j] + ')' + e[j:]))
print(result)


s = "1*" + raw_input() + "*1"
n = len(s)
sol = 0

for i in range(n):
    if s[i] == '*':
        for j in range(i + 1, n):
            if s[j] == '*':
                sol = max(sol, eval(s[:i + 1] + '(' + s[i + 1:j] + ')' + s[j:]))

print sol


s = raw_input()
pos = [-1]
ans = 0
for R in range(len(s)):
    if ((R == len(s)) or s[R] == '*'):
        for L in pos:
            now = eval(s[:(L + 1)] + "(" + s[(L + 1):R] + ")" + s[R:])
            ans = max(ans, now)
        pos.append(R)
print ans


s = raw_input()
pos = [-1]
ans = 0
for R in range(len(s) + 1):
    if ((R == len(s)) or s[R] == '*'):
        for L in pos:
            ans = max(ans, eval(s[:L + 1] + "(" + s[L + 1:R] + ")" + s[R:]))
        pos.append(R)
print ans


s =  raw_input()

def mul(s):
    ans = 1
    l = map(int,s.split("*"))
    for i in l:
        ans = ans*i
    return ans

def calc(s):
    if s == '':
        return 1
    return sum(map(mul,s.split("+")))

l = s.split("*")

ans = 0

# print l

for i in xrange(len(l)):
    for j in xrange(i,len(l)):
        x = calc("*".join(l[i:j]))
        ss = "*".join(l[:i]) +  "*" +  str(x) + "*" + "*".join(l[j:])
        if ss[0] == "*":
            ss = ss[1:]
        if ss[-1] == "*":
            ss = ss[:-1]
        print ss
        ans = max(ans,calc(ss))

print ans


s = raw_input()

def mul(s):
    ans = 1
    l = map(int,s.split("*"))
    for i in l:
        ans = ans*i
    return ans

def calc(s):
    if s == '':
        return 0
    return sum(map(mul,s.split("+")))

l = s.split("*")

ans = 0

# print l

for i in xrange(len(l)):
    for j in xrange(i,len(l)):
        x = calc("*".join(l[i:j]))
        ss = "*".join(l[:i]) +  "*" +  str(x) + "*" + "*".join(l[j:])
        if ss[0] == "*":
            ss = ss[1:]
        if ss[-1] == "*":
            ss = ss[:-1]
        #print ss
        ans = max(ans,calc(ss))

print ans


s = raw_input()

s = "1*" + s + "*1"

def mul(s):
    ans = 1
    l = map(int,s.split("*"))
    for i in l:
        ans = ans*i
    return ans

def calc(s):
    if s == '':
        return 0
    return sum(map(mul,s.split("+")))

l = s.split("*")

ans = 0

# print l

for i in xrange(len(l)):
    for j in xrange(i,len(l)):
        x = calc("*".join(l[i:j]))
        ss = "*".join(l[:i]) +  "*" +  str(x) + "*" + "*".join(l[j:])
        if ss[0] == "*":
            ss = ss[1:]
        if ss[-1] == "*":
            ss = ss[:-1]
        #print ss
        ans = max(ans,calc(ss))

print ans


s = raw_input()

def mul(s):
    ans = 1
    l = map(int,s.split("*"))
    for i in l:
        ans = ans*i
    return ans

def calc(s):
    if s == '':
        return 0
    return sum(map(mul,s.split("+")))

ans = 0

for i in xrange(0,len(s),2):
    for j in xrange(i+2,len(s),2):
        tmp = calc(s[:i] + str(calc(s[i:j+1])) + s[j+1:])
        # print i,j,s[:i] + str(calc(s[i:j+1])) + s[j+1:],tmp
        ans = max(ans,tmp)

print ans


#include <iostream>
using namespace std;
#define N 300
int b[N];

int main() {
    int n;
    while(cin>>n) {
        for(int i = 0;i < n;++i) cin>> b[i];
        int last[N] = {};
        int t=b[0];
        int d=0, d_=0;
        while(t > 0) {
            last[d]=t%10;
            t /= 10;
            d++;
        }
        d_= d;
        while(d>0) {
            cout << last[d-1]; d--;
        }
        cout << endl;

        for(int i = 1;i < n;++i) {
            t = b[i]-b[i-1];
            if(t > 0) {
                d=0;
                while(t > 0 | d < d_) {
                    int x=min(t+last[d], 9);
                    if(d < d_-1 && t == last[d]) {
                        last[d] =0;
                    } else {
                        t -= x-last[d];
                        last[d] = x;
                    }
                    d++;
                }
            } else if(t<0) {
                d = d_ + 1;
                last[d-1] = 1; t = b[i]-1;
                for(int i=0; i < d-1;++i) {
                    last[i] = t%10; t /= 10;
                }
            } else d = d_;
            d_ = d;

            while(d > 0) { cout<< last[d-1]; d--; }
            cout << endl;
        }
    }
    return 0;
}


#include<map>
#include<set>
#include<cmath>
#include<ctime>
#include<stack>
#include<queue>
#include<cstdio>
#include<cctype>
#include<string>
#include<vector>
#include<cstring>
#include<iomanip>
#include<iostream>
#include<algorithm>
#include<functional>
#define fuck(x) cout<<"["<<x<<"]"
#define FIN freopen("input.txt","r",stdin)
#define FOUT freopen("output.txt","w+",stdout)
using namespace std;
typedef long long LL;
typedef pair<int, int>PII;

const int MX = 1e5 + 5;
const int mod = 1e9 + 7;
const int INF = 0x3f3f3f3f;

int A[MX], B[MX];
int minlen(int x) {
    return (x - 1) / 9 + 1;
}
int getmin(int A[], int len, int x) {
    if(x - (len - 1) * 9 > 0) A[1] = x - (len - 1) * 9;
    else A[1] = 1, x--;
    for(int i = len; i >= 2; i--) {
        A[i] = min(x, 9);
        x -= A[i];
    }
    return len;
}
void getmax(int A[], int len, int x) {
    for(int i = 1; i <= len; i++) {
        A[i] = min(x, 9);
        x -= A[i];
    }
}
bool isok(int A[], int len, int x) {
    getmax(B, len, x);
    for(int i = 1; i <= len; i++) {
        if(A[i] < B[i]) return true;
        if(A[i] > B[i]) return false;
    }
    return false;
}

int main() {
    int n, x; //FIN;
    while(~scanf("%d", &n)) {
        int len;
        for(int i = 1; i <= n; i++) {
            scanf("%d", &x);
            if(i == 1) {
                len = getmin(A, minlen(x), x);
            } else {
                int l = minlen(x);
                if(l > len) len = getmin(A, l, x);
                else if(!isok(A, len, x)) len = getmin(A, len + 1, x);
                else {
                    int t, p = 0, left = 0, a, b;
                    for(int j = 1; j <= len; j++) {
                        left += A[j];
                        t = max((x - left) - (len - j) * 9, 1);
                        if(x - left >= 0 && A[j] + t <= 9) p = j, a = left, b = t;
                    }
                    A[p] += b; getmin(A + p, len - p, x - a - b);
                }
            }
            for(int j = 1; j <= len; j++) printf("%d", A[j]);
            printf("\n");
        }
    }
    return 0;
}


#include<map>
#include<set>
#include<cmath>
#include<ctime>
#include<stack>
#include<queue>
#include<cstdio>
#include<cctype>
#include<string>
#include<vector>
#include<cstring>
#include<iomanip>
#include<iostream>
#include<algorithm>
#include<functional>
#define fuck(x) cout<<"["<<x<<"]"
#define FIN freopen("input.txt","r",stdin)
#define FOUT freopen("output.txt","w+",stdout)
using namespace std;
typedef long long LL;
typedef pair<int, int>PII;

const int MX = 1e5 + 5;
const int mod = 1e9 + 7;
const int INF = 0x3f3f3f3f;

int A[MX], B[MX];
int minlen(int x) {
    return (x - 1) / 9 + 1;
}
int getmin(int A[], int len, int x) {
    if(x - (len - 1) * 9 > 0) A[1] = x - (len - 1) * 9;
    else A[1] = 1, x--;
    for(int i = len; i >= 2; i--) {
        A[i] = min(x, 9);
        x -= A[i];
    }
    return len;
}
void MIN(int A[], int len, int x){
    for(int i = len; i >= 1; i--) {
        A[i] = min(x, 9);
        x -= A[i];
    }
}
void getmax(int A[], int len, int x) {
    for(int i = 1; i <= len; i++) {
        A[i] = min(x, 9);
        x -= A[i];
    }
}
bool isok(int A[], int len, int x) {
    getmax(B, len, x);
    for(int i = 1; i <= len; i++) {
        if(A[i] < B[i]) return true;
        if(A[i] > B[i]) return false;
    }
    return false;
}

int main() {
    int n, x; //FIN;
    while(~scanf("%d", &n)) {
        int len;
        for(int i = 1; i <= n; i++) {
            scanf("%d", &x);
            if(i == 1) {
                len = getmin(A, minlen(x), x);
            } else {
                int l = minlen(x);
                if(l > len) len = getmin(A, l, x);
                else if(!isok(A, len, x)) len = getmin(A, len + 1, x);
                else {
                    int t, p = 0, left = 0, a, b;
                    for(int j = 1; j <= len; j++) {
                        left += A[j];
                        t = max((x - left) - (len - j) * 9, 1);
                        if(x - left > 0 && A[j] + t <= 9) p = j, a = left, b = t;
                    }
                    A[p] += b; MIN(A + p, len - p, x - a - b);
                }
            }
            for(int j = 1; j <= len; j++) printf("%d", A[j]);
            printf("\n");
        }
    }
    return 0;
}


#include<map>
#include<set>
#include<cmath>
#include<ctime>
#include<stack>
#include<queue>
#include<cstdio>
#include<cctype>
#include<string>
#include<vector>
#include<cstring>
#include<iomanip>
#include<iostream>
#include<algorithm>
#include<functional>
#define fuck(x) cout<<"["<<x<<"]"
#define FIN freopen("input.txt","r",stdin)
#define FOUT freopen("output.txt","w+",stdout)
using namespace std;
typedef long long LL;
typedef pair<int, int>PII;

const int MX = 1e5 + 5;
const int mod = 1e9 + 7;
const int INF = 0x3f3f3f3f;

int A[MX], B[MX];
int minlen(int x) {
    return (x - 1) / 9 + 1;
}
int getmin(int A[], int len, int x) {
    if(!x) {
        for(int i = 1; i <= len; i++) A[i] = 0;
        return len;
    }
    if(x - (len - 1) * 9 > 0) A[1] = x - (len - 1) * 9;
    else A[1] = 1, x--;
    for(int i = len; i >= 2; i--) {
        A[i] = min(x, 9);
        x -= A[i];
    }
    return len;
}
void getmax(int A[], int len, int x) {
    for(int i = 1; i <= len; i++) {
        A[i] = min(x, 9);
        x -= A[i];
    }
}
bool isok(int A[], int len, int x) {
    getmax(B, len, x);
    for(int i = 1; i <= len; i++) {
        if(A[i] < B[i]) return true;
        if(A[i] > B[i]) return false;
    }
    return false;
}

int main() {
    int n, x; //FIN;
    while(~scanf("%d", &n)) {
        int len;
        for(int i = 1; i <= n; i++) {
            scanf("%d", &x);
            if(i == 1) {
                len = getmin(A, minlen(x), x);
            } else {
                int l = minlen(x);
                if(l > len) len = getmin(A, l, x);
                else if(!isok(A, len, x)) len = getmin(A, len + 1, x);
                else {
                    int t, p = 0, left = 0, a, b;
                    for(int j = 1; j <= len; j++) {
                        left += A[j];
                        t = max((x - left) - (len - j) * 9, 1);
                        if(x - left > 0 && A[j] + t <= 9) p = j, a = left, b = t;
                    }
                    A[p] += b; getmin(A + p, len - p, x - a - b);
                }
            }
            for(int j = 1; j <= len; j++) printf("%d", A[j]);
            printf("\n");
        }
    }
    return 0;
}


#include<map>
#include<set>
#include<cmath>
#include<ctime>
#include<stack>
#include<queue>
#include<cstdio>
#include<cctype>
#include<string>
#include<vector>
#include<cstring>
#include<iomanip>
#include<iostream>
#include<algorithm>
#include<functional>
#define fuck(x) cout<<"["<<x<<"]"
#define FIN freopen("input.txt","r",stdin)
#define FOUT freopen("output.txt","w+",stdout)
using namespace std;
typedef long long LL;
typedef pair<int, int>PII;

const int MX = 1e5 + 5;
const int mod = 1e9 + 7;
const int INF = 0x3f3f3f3f;

int A[MX], B[MX];
int minlen(int x) {
    return (x - 1) / 9 + 1;
}
int getmin(int A[], int len, int x) {
    if(x - (len - 1) * 9 > 0) A[1] = x - (len - 1) * 9;
    else A[1] = 1, x--;
    for(int i = len; i >= 2; i--) {
        A[i] = min(x, 9);
        x -= A[i];
    }
    return len;
}
void getmax(int A[], int x) {
    int len = 1;
    while(x) {
        A[len] = min(x, 9);
        x -= A[len++];
    }
}
bool isok(int A[], int len, int x) {
    getmax(B, x);
    for(int i = 1; i <= len; i++) {
        if(A[i] < B[i]) return true;
        if(A[i] > B[i]) return false;
    }
    return false;
}

int main() {
    int n, x; //FIN;
    while(~scanf("%d", &n)) {
        int len, last, now;
        for(int i = 1; i <= n; i++) {
            scanf("%d", &x); now = x;
            if(i == 1) {
                len = getmin(A, minlen(x), x);
            } else {
                int l = minlen(x);
                if(l > len) len = getmin(A, l, x);
                else if(!isok(A, len, x)) len = getmin(A, len + 1, x);
                else {
                    if(x <= last) {
                        int j; x = last - x + 1;
                        for(j = len; j >= 1 && x; j--) {
                            int t = min(A[j], x);
                            x -= t; A[j] -= t;
                        }
                        for(x = 1; j >= 1 && x; j--) {
                            A[j] += x;
                            x = A[j] / 10;
                            A[j] %= 10;
                        }
                    } else {
                        x -= last;
                        for(int j = len; j >= 1; j--) {
                            int t = min(9 - A[j], x);
                            x -= t; A[j] += t;
                        }
                    }
                }
            }
            last = now;
            for(int j = 1; j <= len; j++) printf("%d", A[j]);
            printf("\n");
        }
    }
    return 0;
}


#include<map>
#include<set>
#include<cmath>
#include<ctime>
#include<stack>
#include<queue>
#include<cstdio>
#include<cctype>
#include<string>
#include<vector>
#include<cstring>
#include<iomanip>
#include<iostream>
#include<algorithm>
#include<functional>
#define fuck(x) cout<<"["<<x<<"]"
#define FIN freopen("input.txt","r",stdin)
#define FOUT freopen("output.txt","w+",stdout)
using namespace std;
typedef long long LL;
typedef pair<int, int>PII;

const int MX = 1e5 + 5;
const int mod = 1e9 + 7;
const int INF = 0x3f3f3f3f;

int A[MX], B[MX];
int minlen(int x) {
    return (x - 1) / 9 + 1;
}
int getmin(int A[], int len, int x) {
    if(!x) {
        for(int i = 1; i <= len; i++) A[i] = 0;
        return len;
    }
    if(x - (len - 1) * 9 > 0) A[1] = x - (len - 1) * 9;
    else A[1] = 1, x--;
    for(int i = len; i >= 2; i--) {
        A[i] = min(x, 9);
        x -= A[i];
    }
    return len;
}
void getmax(int A[], int len, int x) {
    for(int i = 1; i <= len; i++) {
        A[i] = min(x, 9);
        x -= A[i];
    }
}
bool isok(int A[], int len, int x) {
    getmax(B, len, x);
    for(int i = 1; i <= len; i++) {
        if(A[i] < B[i]) return true;
        if(A[i] > B[i]) return false;
    }
    return false;
}

int main() {
    int n, x; //FIN;
    while(~scanf("%d", &n)) {
        int len;
        for(int i = 1; i <= n; i++) {
            scanf("%d", &x);
            if(i == 1) {
                len = getmin(A, minlen(x), x);
            } else {
                int l = minlen(x);
                if(l > len) len = getmin(A, l, x);
                else if(!isok(A, len, x)) len = getmin(A, len + 1, x);
                else {
                    int t, p = 0, left = 0, a, b;
                    for(int j = 1; j <= len; j++) {
                        left += A[j];
                        t = max((x - left) - (len - j) * 9, 1);
                        if(x - left >= 0 && A[j] + t <= 9) p = j, a = left, b = t;
                    }
                    A[p] += b; getmin(A + p, len - p, x - a - b);
                }
            }
            for(int j = 1; j <= len; j++) printf("%d", A[j]);
            printf("\n");
        }
    }
    return 0;
}


#include<map>
#include<set>
#include<cmath>
#include<ctime>
#include<stack>
#include<queue>
#include<cstdio>
#include<cctype>
#include<string>
#include<vector>
#include<cstring>
#include<iomanip>
#include<iostream>
#include<algorithm>
#include<functional>
#define fuck(x) cout<<"["<<x<<"]"
#define FIN freopen("input.txt","r",stdin)
#define FOUT freopen("output.txt","w+",stdout)
using namespace std;
typedef long long LL;
typedef pair<int, int>PII;

const int MX = 1e5 + 5;
const int mod = 1e9 + 7;
const int INF = 0x3f3f3f3f;

int A[MX], B[MX];
int minlen(int x) {
    return (x - 1) / 9 + 1;
}
int getmin(int A[], int len, int x) {
    if(x - (len - 1) * 9 > 0) A[1] = x - (len - 1) * 9;
    else A[1] = 1, x--;
    for(int i = len; i >= 2; i--) {
        A[i] = min(x, 9);
        x -= A[i];
    }
    return len;
}
void getmax(int A[], int len, int x) {
    for(int i = 1; i <= len; i++) {
        A[i] = min(x, 9);
        x -= A[i];
    }
}
bool isok(int A[], int len, int x) {
    getmax(B, len, x);
    for(int i = 1; i <= len; i++) {
        if(A[i] < B[i]) return true;
        if(A[i] > B[i]) return false;
    }
    return false;
}

int main() {
    int n, x; //FIN;
    while(~scanf("%d", &n)) {
        int len;
        for(int i = 1; i <= n; i++) {
            scanf("%d", &x);
            if(i == 1) {
                len = getmin(A, minlen(x), x);
            } else {
                int l = minlen(x);
                if(l > len) len = getmin(A, l, x);
                else if(!isok(A, len, x)) len = getmin(A, len + 1, x);
                else {
                    int t, p, left = 0, a, b;
                    for(int j = 1; j <= len; j++) {
                        left += A[j];
                        t = x - left - (len - j) * 9;
                        if(t < 0) t = 1;
                        if(t > 0 && A[j] + t <= 9) p = j, a = left, b = t;
                    }
                    A[p] += b; getmin(A + p, len - p, x - a - b);
                }
            }
            for(int j = 1; j <= len; j++) printf("%d", A[j]);
            printf("\n");
        }
    }
    return 0;
}