import java.util.ArrayList;
import java.util.Scanner;
import java.lang.StringBuilder;
import java.util.Arrays;
import java.util.Stack;
import java.util.TreeMap;
public class Test11   {
    public static int getdig(long a) {
        long l = a;
        int ans = 0;
        while (l > 0)  {
            l = l / 10;
            ans++;
        }
        return ans;
    }
    public static int getdig2(long a) {
        if (a == 0) return 0;
        long l = a;
        int ans = 0;
        while (l > 0)  {
            l = l / 10;
            ans++;
        }
        return ans + 1;
    }
    public static void main(String[] Args)   {
        Scanner sc = new Scanner(System.in);
        Long n = sc.nextLong();
         if (n == 1000000000) System.out.println("10^10");
         else {
             String ans = n.toString();
             int min = getdig(n);
             //case 1 pw * pw + num
             for (Integer a = 2; a <= 999; a++)  {
                 long pow1 = a * a;
                 Integer b = 2;
                 while (pow1 <= n / 1000)  {
                     for (Integer c = 2; c <= 9; c++)  {
                         long pow2 = c * c;
                         Integer d = 2;
                         while (pow1 * pow2 < n)  {
                             Long res = n - pow1 * pow2;
                             if (getdig2(res) + getdig(a) +getdig(b) + 5 < min)  {
                                 min = getdig2(res) + getdig(a) +getdig(b) + 5;
                                 if (res == 0) ans = a.toString() + '^' + b.toString() + '*' + c.toString() + '^' + d.toString();
                                 else ans = a.toString() + '^' + b.toString() + '*' + c.toString() + '^' + d.toString() + '+' + res.toString();
                             }
                             pow2 *= c;
                             d++;
                         }
                     }
                     pow1 *= a;
                     b++;
                 }
             }
             //case 2: pw + num;
             for (Long a = new Long("2"); a <= 399999; a++)  {
                 Integer b = 2;
                 long pw = a * a;
                 while (pw <= n)  {
                     Long res = n - pw;
                     if (getdig2(res) + getdig(a) + getdig(b) < min)  {
                         min = getdig2(res) + getdig(a) + getdig(b);
                         if (res == 0) ans = a.toString() + '^' + b.toString();
                          else ans = a.toString() + '^' + b.toString() + '+' + res.toString();
                     }
                     pw *= (long)a;
                     b++;
                 }
             }
             //case 3: pw + pw + num
             for (Long a = new Long("2"); a <= 999; a++)  {
                 Integer b= 2;
                 long pw = a * a;
                 while (pw <= n)  {
                     for (Long c = new Long("2"); c <= 99; c++)  {
                         Integer d = 2;
                         long pw2 = c * c;
                         while (pw2 + pw<= n)  {

                             Long res = n - pw - pw2;
                             if (getdig2(res) + getdig(a) + getdig(b) + getdig(c) + getdig(d) < min)  {
                                 min = getdig2(res) + getdig(a) + getdig(b) + getdig(c) + getdig(d);
                                if (res == 0) ans = a.toString() + '^' + b.toString() + '+' + c.toString() + '^' + d.toString();
                                 else ans = a.toString() + '^' + b.toString() + '+' + c.toString() + '^' + d.toString() + '+' + res.toString();
                             }
                             pw2 *= c;
                             d++;
                         }
                     }
                     pw *= a;
                     b++;
                 }
             }
             //case 4 : pw + pw * num
             for (Integer a = 2; a <= 9; a++)  {
                 Integer b= 2;
                 long pw = a * a;
                 while (pw <= n && b <= 9)  {
                     for (Integer c = 2; c <= 9; c++)  {
                         Integer d = 2;
                         long pw2 = c * c;
                         while (pw2 + pw<= n && d <= 9)  {

                             Long res = (n - pw) / pw2;
                             if (min == 10 && res <= 9 && (n - pw) % pw2  == 0)  {
                                 min = 9;
                                 ans = a.toString() + '^' + b.toString() + '+' + c.toString() + '^' + d.toString() + '*' + res.toString();
                             }
                             pw2 *= c;
                             d++;
                         }
                     }
                     pw *= a;
                     b++;
                 }
             }
             //case 5 : pw * pw * num
              for (Integer a = 2; a <= 9; a++)  {
                 Integer b= 2;
                 long pw = a * a;
                 while (pw <= n && b <= 9)  {
                     for (Integer c = 2; c <= 9; c++)  {
                         Integer d = 2;
                         long pw2 = c * c;
                         while (pw2 * pw<= n && d <= 9)  {

                             Long res = (n / pw) / pw2;
                             if (min == 10 && res <= 9 && n  == pw * pw2 * res)  {
                                 min = 9;
                                 ans = a.toString() + '^' + b.toString() + '*' + c.toString() + '^' + d.toString() + '*' + res.toString();
                             }
                             pw2 *= c;
                             d++;
                         }
                     }
                     pw *= a;
                     b++;
                 }
             }
            //case 6: pw *  num + num
              for (Long a = new Long("2"); a <= 99999; a++)  {
                  Integer b = 2;
                  long pw = a * a;
                  while (pw <= n)  {
                      Long num1 = n / pw;
                      Long num2 = n % pw;
                      if (min > getdig2(num1) + getdig(a) + getdig(b) + getdig(num2))  {
                          min = getdig2(num1) + getdig(a) + getdig(b) + getdig(num2);
                          if (num2 == 0)ans = a.toString() + '^' + b.toString() + '*' +num1.toString();
                          else ans = a.toString() + '^' + b.toString() + '*' +num1.toString() + '+' + num2.toString();
                      }
                      b++;
                      pw *= a;
                  }
              }
         System.out.println(ans);
         }

   }
}


import java.util.ArrayList;
import java.util.Scanner;
import java.lang.StringBuilder;
import java.util.Arrays;
import java.util.Stack;
import java.util.TreeMap;
public class Test11   {
    public static int getdig(long a) {
        long l = a;
        int ans = 0;
        while (l > 0)  {
            l = l / 10;
            ans++;
        }
        return ans;
    }
    public static int getdig2(long a) {
        if (a == 0) return 0;
        long l = a;
        int ans = 0;
        while (l > 0)  {
            l = l / 10;
            ans++;
        }
        return ans + 1;
    }
    public static void main(String[] Args)   {
        Scanner sc = new Scanner(System.in);
        Long n = sc.nextLong();
         if (n == 1000000000) System.out.println("10^10");
         else {
             String ans = n.toString();
             int min = getdig(n);
             //case 1 pw * pw + num
             for (Integer a = 2; a <= 999; a++)  {
                 long pow1 = a * a;
                 Integer b = 2;
                 while (pow1 <= n / 1000)  {
                     for (Integer c = 2; c <= 9; c++)  {
                         long pow2 = c * c;
                         Integer d = 2;
                         while (pow1 * pow2 < n)  {
                             Long res = n - pow1 * pow2;
                             if (getdig2(res) + getdig(a) +getdig(b) + getdig(c) + getdig(d) + 3 < min)  {
                                 min = getdig2(res) + getdig(a) +getdig(b) + getdig(c) + getdig(d) + 3;
                                 if (res == 0) ans = a.toString() + '^' + b.toString() + '*' + c.toString() + '^' + d.toString();
                                 else ans = a.toString() + '^' + b.toString() + '*' + c.toString() + '^' + d.toString() + '+' + res.toString();
                             }
                             pow2 *= c;
                             d++;
                         }
                     }
                     pow1 *= a;
                     b++;
                 }
             }
             //case 2: pw + num;
             for (Long a = new Long("2"); a <= 399999; a++)  {
                 Integer b = 2;
                 long pw = a * a;
                 while (pw <= n)  {
                     Long res = n - pw;
                     if (getdig2(res) + getdig(a) + getdig(b) + 1< min)  {
                         min = getdig2(res) + getdig(a) + getdig(b) + 1;
                         if (res == 0) ans = a.toString() + '^' + b.toString();
                          else ans = a.toString() + '^' + b.toString() + '+' + res.toString();
                     }
                     pw *= (long)a;
                     b++;
                 }
             }
             //case 3: pw + pw + num
             for (Long a = new Long("2"); a <= 999; a++)  {
                 Integer b= 2;
                 long pw = a * a;
                 while (pw <= n)  {
                     for (Long c = new Long("2"); c <= 99; c++)  {
                         Integer d = 2;
                         long pw2 = c * c;
                         while (pw2 + pw<= n)  {

                             Long res = n - pw - pw2;
                             if (getdig2(res) + getdig(a) + getdig(b) + getdig(c) + getdig(d) + 3< min)  {
                                 min = getdig2(res) + getdig(a) + getdig(b) + getdig(c) + getdig(d) + 3;
                                if (res == 0) ans = a.toString() + '^' + b.toString() + '+' + c.toString() + '^' + d.toString();
                                 else ans = a.toString() + '^' + b.toString() + '+' + c.toString() + '^' + d.toString() + '+' + res.toString();
                             }
                             pw2 *= c;
                             d++;
                         }
                     }
                     pw *= a;
                     b++;
                 }
             }
             //case 4 : pw + pw * num
             for (Integer a = 2; a <= 9; a++)  {
                 Integer b= 2;
                 long pw = a * a;
                 while (pw <= n && b <= 9)  {
                     for (Integer c = 2; c <= 9; c++)  {
                         Integer d = 2;
                         long pw2 = c * c;
                         while (pw2 + pw<= n && d <= 9)  {

                             Long res = (n - pw) / pw2;
                             if (min == 10 && res <= 9 && (n - pw) % pw2  == 0)  {
                                 min = 9;
                                 ans = a.toString() + '^' + b.toString() + '+' + c.toString() + '^' + d.toString() + '*' + res.toString();
                             }
                             pw2 *= c;
                             d++;
                         }
                     }
                     pw *= a;
                     b++;
                 }
             }
             //case 5 : pw * pw * num
              for (Integer a = 2; a <= 9; a++)  {
                 Integer b= 2;
                 long pw = a * a;
                 while (pw <= n && b <= 9)  {
                     for (Integer c = 2; c <= 9; c++)  {
                         Integer d = 2;
                         long pw2 = c * c;
                         while (pw2 * pw<= n && d <= 9)  {

                             Long res = (n / pw) / pw2;
                             if (min == 10 && res <= 9 && n  == pw * pw2 * res)  {
                                 min = 9;
                                 ans = a.toString() + '^' + b.toString() + '*' + c.toString() + '^' + d.toString() + '*' + res.toString();
                             }
                             pw2 *= c;
                             d++;
                         }
                     }
                     pw *= a;
                     b++;
                 }
             }
            //case 6: pw *  num + num
              for (Long a = new Long("2"); a <= 99999; a++)  {
                  Integer b = 2;
                  long pw = a * a;
                  while (pw <= n)  {
                      Long num1 = n / pw;
                      Long num2 = n % pw;
                      if (min > getdig(num1) + getdig(a) + getdig(b) + getdig2(num2) + 2)  {
                          min = getdig(num1) + getdig(a) + getdig(b) + getdig2(num2) + 2;
                          if (num2 == 0)ans = a.toString() + '^' + b.toString() + '*' +num1.toString();
                          else ans = a.toString() + '^' + b.toString() + '*' +num1.toString() + '+' + num2.toString();
                      }
                      b++;
                      pw *= a;
                  }
              }
         System.out.println(ans);
         }
   }
}


import java.util.ArrayList;
import java.util.Scanner;
import java.lang.StringBuilder;
import java.util.Arrays;
import java.util.Stack;
import java.util.TreeMap;
public class Test11   {
    public static int getdig(long a) {
        long l = a;
        int ans = 0;
        while (l > 0)  {
            l = l / 10;
            ans++;
        }
        return ans;
    }
    public static int getdig2(long a) {
        if (a == 0) return 0;
        long l = a;
        int ans = 0;
        while (l > 0)  {
            l = l / 10;
            ans++;
        }
        return ans + 1;
    }
    public static void main(String[] Args)   {
        Scanner sc = new Scanner(System.in);
        Long n = sc.nextLong();
         if (n == 1000000000) System.out.println("10^10");
         else {
             String ans = n.toString();
             int min = getdig(n);
             //case 1 pw * pw + num
             for (Integer a = 2; a <= 999; a++)  {
                 long pow1 = a * a;
                 Integer b = 2;
                 while (pow1 <= n / 1000)  {
                     for (Integer c = 2; c <= 9; c++)  {
                         long pow2 = c * c;
                         Integer d = 2;
                         while (pow1 * pow2 < n)  {
                             Long res = n - pow1 * pow2;
                             if (getdig2(res) + getdig(a) +getdig(b) + 5 < min)  {
                                 min = getdig2(res) + getdig(a) +getdig(b) + 5;
                                 if (res == 0) ans = a.toString() + '^' + b.toString() + '*' + c.toString() + '^' + d.toString();
                                 else ans = a.toString() + '^' + b.toString() + '*' + c.toString() + '^' + d.toString() + '+' + res.toString();
                             }
                             pow2 *= c;
                             d++;
                         }
                     }
                     pow1 *= a;
                     b++;
                 }
             }
             //case 2: pw + num;
             for (Long a = new Long("2"); a <= 99999; a++)  {
                 Integer b = 2;
                 long pw = a * a;
                 while (pw <= n)  {
                     Long res = n - pw;
                     if (getdig2(res) + getdig(a) + getdig(b) < min)  {
                         min = getdig2(res) + getdig(a) + getdig(b);
                         if (res == 0) ans = a.toString() + '^' + b.toString();
                          else ans = a.toString() + '^' + b.toString() + '+' + res.toString();
                     }
                     pw *= (long)a;
                     b++;
                 }
             }
             //case 3: pw + pw + num
             for (Long a = new Long("2"); a <= 999; a++)  {
                 Integer b= 2;
                 long pw = a * a;
                 while (pw <= n)  {
                     for (Long c = new Long("2"); c <= 99; c++)  {
                         Integer d = 2;
                         long pw2 = c * c;
                         while (pw2 + pw<= n)  {

                             Long res = n - pw - pw2;
                             if (getdig2(res) + getdig(a) + getdig(b) + getdig(c) + getdig(d) < min)  {
                                 min = getdig2(res) + getdig(a) + getdig(b) + getdig(c) + getdig(d);
                                if (res == 0) ans = a.toString() + '^' + b.toString() + '+' + c.toString() + '^' + d.toString();
                                 else ans = a.toString() + '^' + b.toString() + '+' + c.toString() + '^' + d.toString() + '+' + res.toString();
                             }
                             pw2 *= c;
                             d++;
                         }
                     }
                     pw *= a;
                     b++;
                 }
             }
             //case 4 : pw + pw * num
             for (Integer a = 2; a <= 9; a++)  {
                 Integer b= 2;
                 long pw = a * a;
                 while (pw <= n && b <= 9)  {
                     for (Integer c = 2; c <= 9; c++)  {
                         Integer d = 2;
                         long pw2 = c * c;
                         while (pw2 + pw<= n && d <= 9)  {

                             Long res = (n - pw) / pw2;
                             if (min == 10 && res <= 9 && (n - pw) % pw2  == 0)  {
                                 min = 9;
                                 ans = a.toString() + '^' + b.toString() + '+' + c.toString() + '^' + d.toString() + '*' + res.toString();
                             }
                             pw2 *= c;
                             d++;
                         }
                     }
                     pw *= a;
                     b++;
                 }
             }
             //case 5 : pw * pw * num
              for (Integer a = 2; a <= 9; a++)  {
                 Integer b= 2;
                 long pw = a * a;
                 while (pw <= n && b <= 9)  {
                     for (Integer c = 2; c <= 9; c++)  {
                         Integer d = 2;
                         long pw2 = c * c;
                         while (pw2 * pw<= n && d <= 9)  {

                             Long res = (n / pw) / pw2;
                             if (min == 10 && res <= 9 && n  == pw * pw2 * res)  {
                                 min = 9;
                                 ans = a.toString() + '^' + b.toString() + '*' + c.toString() + '^' + d.toString() + '*' + res.toString();
                             }
                             pw2 *= c;
                             d++;
                         }
                     }
                     pw *= a;
                     b++;
                 }
             }
            //case 6: pw *  num + num
              for (Long a = new Long("2"); a <= 99999; a++)  {
                  Integer b = 2;
                  long pw = a * a;
                  while (pw <= n)  {
                      Long num1 = n / pw;
                      Long num2 = n % pw;
                      if (min > getdig2(num1) + getdig(a) + getdig(b) + getdig(num2))  {
                          min = getdig2(num1) + getdig(a) + getdig(b) + getdig(num2);
                          if (num2 == 0)ans = a.toString() + '^' + b.toString() + '*' +num1.toString();
                          else ans = a.toString() + '^' + b.toString() + '*' +num1.toString() + '+' + num2.toString();
                      }
                      b++;
                      pw *= a;
                  }
              }
         System.out.println(ans);
         }

   }
}


#include <iostream>
#include <string>
#include <sstream>
#include <map>
#include <cmath>
using namespace std;

int main(){
	map <long long, string> pre;
	long long n,sum,lltemp1,lltemp2;
	stringstream sstemp;
	string stemp1,stemp2,result;
	map <long long, string>::iterator it;
	cin >> n;
	if (n == 10000000000){
		cout << "10^10";
		return 0;
	}
	pre.clear();
	for (long long i = 2; i <= (long long)sqrt(n); i++){
		sum = i;
		for (long long j = 2; j <= log(n) / log(2); j++){
			if (n / i < sum)
				break;
			sum *= i;
			sstemp.str("");
			sstemp << i;
			stemp1 = sstemp.str();
			sstemp.str("");
			sstemp << j;
			stemp2 = sstemp.str();
			stemp1 = stemp1 + "^" + stemp2;
			if (pre.find(sum) != pre.end()){
				if (pre[sum].length() > stemp1.length())
					pre[sum] = stemp1;
			}
			else{
				pre.insert(make_pair(sum,stemp1));
			}
		}
	}
	sstemp.str("");
	sstemp << n;
	stemp1 = sstemp.str();
	result = stemp1;
	for (long long i = 2; i <= (long long)sqrt(n); i++){
		sum = i;
		for (long long j = 2; j <= log(n) / log(2); j++){
			if (n / i < sum)
				break;
			sum *= i;
			stemp2 = pre[sum];
			lltemp1 = n / sum;
			if (lltemp1 > 1){
				sstemp.str("");
				sstemp << lltemp1;
				stemp1 = sstemp.str();
				it = pre.find(lltemp1);
				if (it != pre.end()){
					if (pre[lltemp1].length() < stemp1.length()){
						stemp2 = stemp2 + "*" + pre[lltemp1];
					}
					else{
						stemp2 = stemp2 + "*" + stemp1;
					}
				}
				else{
					stemp2 = stemp2 + "*" + stemp1;
				}
			}
			lltemp2 = n - sum * lltemp1;
			if (lltemp2 > 1){
				sstemp.str("");
				sstemp << lltemp2;
				stemp1 = sstemp.str();
				it = pre.find(lltemp2);
				if (it != pre.end()){
					if (pre[lltemp2].length() < stemp1.length()){
						stemp2 = stemp2 + "+" + pre[lltemp2];
					}
					else{
						stemp2 = stemp2 + "+" + stemp1;
					}
				}
				else{
					stemp2 = stemp2 + "+" + stemp1;
				}
			}
			else{
				if (lltemp2 == 1){
					stemp2 = stemp2 + "+1";
				}
			}
			if (stemp2.length() < result.length())
				result = stemp2;
		}
	}
	cout << result;
	return 0;
}


using namespace std ;
#include <bits/stdc++.h>
#define TASK "F"
#define long long long

long lNumber ;
int iSqrtNumber ;
string strNumber ;
size_t szNumberLength ;
map < long , int > mLength ;
map < long , string > mExpression ;

string toString(long number)
{
    string convert ;
    for ( ; number != 0 ; number /= 10)
        convert = char(number % 10 + '0') + convert ;
    return convert ;
}
size_t length(long number)
{
    int length = 0 ;
    for ( ; number != 0 ; number /= 10) ++length ;
    return length ;
}
size_t getLength(const long& number)
{
    if (mLength.count(number))
        return mLength[number] ;
    return length(number) ;
}
string getExpression(const long& number)
{
    if (mExpression.count(number))
        return mExpression[number] ;
    return toString(number) ;
}

int main()
{
    #ifndef ONLINE_JUDGE
    freopen(TASK".inp" , "r" , stdin) ;
    freopen(TASK".out" , "w" , stdout) ;
    #endif // ONLINE_JUDGE

    ios::sync_with_stdio(false) ;
    cin.tie(0) , cout.tie(0) ;

    scanf("%I64d" , &lNumber) ;
    strNumber = toString(lNumber) ;
    szNumberLength = strNumber.length() ;
    iSqrtNumber = sqrt(lNumber) ;

    for (long a = 2 ; a <= iSqrtNumber ; ++a)
    {
        long product = a * a ;
        for (long b = 2 ; product <= lNumber ; ++b , product *= a)
        {
            if ((length(a) + length(b) + 1) < getLength(product))
            {
                mLength[product] = length(a) + length(b) + 1 ;
                mExpression[product] = toString(a) + "^" + toString(b) ;
            }
        }
    }

    for (long a = 2 ; a <= iSqrtNumber ; ++a)
    {
        long product = a * a ;
        for (long b = 2 ; product <= lNumber ; ++b , product *= a)
        {
            long div = lNumber / product ;
            long mod = lNumber % product ;

            size_t curLength ;
            if (div != 1) curLength = getLength(div) + getLength(product) + 1 ;
            else curLength = getLength(div * product) ;
            if (mod != 0) curLength += getLength(mod) + 1 ;

            if (curLength < szNumberLength)
            {
                string curExpression ;
                if (div != 1) curExpression = getExpression(div) + "*" + getExpression(product) ;
                else curExpression = getExpression(div * product) ;
                if (mod != 0) curExpression = curExpression + "+" + getExpression(mod) ;

                szNumberLength = curLength ;
                strNumber = curExpression ;
            }
        }
    }

    puts(strNumber.c_str()) ;

    return 0 ;
}


using namespace std ;
#include <bits/stdc++.h>
#define TASK "F"
#define long long long

long lNumber ;
string strNumber ;
size_t szNumberLength ;
map < long , int > mLength ;
map < long , string > mExpression ;

string toString(long number)
{
    string convert ;
    for ( ; number != 0 ; number /= 10)
        convert = char(number % 10 + '0') + convert ;
    return convert ;
}
size_t length(long number)
{
    int length = 0 ;
    for ( ; number != 0 ; number /= 10) ++length ;
    return length ;
}
size_t getLength(const long& number)
{
    if (mLength.count(number))
        return mLength[number] ;
    return length(number) ;
}
string getExpression(const long& number)
{
    if (mExpression.count(number))
        return mExpression[number] ;
    return toString(number) ;
}

int main()
{
    #ifndef ONLINE_JUDGE
    freopen(TASK".inp" , "r" , stdin) ;
    freopen(TASK".out" , "w" , stdout) ;
    #endif // ONLINE_JUDGE

    ios::sync_with_stdio(false) ;
    cin.tie(0) , cout.tie(0) ;

    scanf("%I64d" , &lNumber) ;
    strNumber = toString(lNumber) ;
    szNumberLength = strNumber.length() ;

    for (long a = 2 ; a <= 100000 ; ++a)
    {
        long product = a * a ;
        for (long b = 2 ; product <= lNumber ; ++b , product *= a)
        {
            if ((length(a) + length(b) + 1) < getLength(product))
            {
                mLength[product] = length(a) + length(b) + 1 ;
                mExpression[product] = toString(a) + "^" + toString(b) ;
            }
        }
    }

    for (long a = 2 ; a <= 100000 ; ++a)
    {
        long product = a * a ;
        for (long b = 2 ; product <= lNumber ; ++b , product *= a)
        {
            long div = lNumber / product ;
            long mod = lNumber % product ;

            size_t curLength ;
            if (div != 1) curLength = getLength(div) + getLength(product) + 1 ;
            else curLength = getLength(div * product) ;
            if (mod != 0) curLength += getLength(mod) + 1 ;

            if (curLength < szNumberLength)
            {
                string curExpression ;
                if (div != 1) curExpression = getExpression(div) + "*" + getExpression(product) ;
                else curExpression = getExpression(div * product) ;
                if (mod != 0) curExpression = curExpression + "+" + getExpression(mod) ;

                szNumberLength = curLength ;
                strNumber = curExpression ;
            }
        }
    }

    cout << strNumber << "\n" ;

    return 0 ;
}


using namespace std ;
#include <bits/stdc++.h>
#define TASK "F"
#define long long long

long lNumber ;
int iSqrtNumber ;
string strNumber ;
size_t szNumberLength ;
map < long , int > mLength ;
map < long , string > mExpression ;

string toString(long number)
{
    string convert ;
    for ( ; number != 0 ; number /= 10)
        convert = char(number % 10 + '0') + convert ;
    return convert ;
}
size_t length(long number)
{
    int length = 0 ;
    for ( ; number != 0 ; number /= 10) ++length ;
    return length ;
}
size_t getLength(const long& number)
{
    if (mLength.count(number))
        return mLength[number] ;
    return length(number) ;
}
string getExpression(const long& number)
{
    if (mExpression.count(number))
        return mExpression[number] ;
    return toString(number) ;
}

int main()
{
    #ifndef ONLINE_JUDGE
    freopen(TASK".inp" , "r" , stdin) ;
    freopen(TASK".out" , "w" , stdout) ;
    #endif // ONLINE_JUDGE

    ios::sync_with_stdio(false) ;
    cin.tie(0) , cout.tie(0) ;

    scanf("%I64d" , &lNumber) ;
    strNumber = toString(lNumber) ;
    szNumberLength = strNumber.length() ;
    iSqrtNumber = sqrt(lNumber) ;

    for (long a = 2 ; a <= iSqrtNumber ; ++a)
    {
        long product = a * a ;
        for (long b = 2 ; product <= lNumber ; ++b , product *= a)
        {
            if ((length(a) + length(b) + 1) < getLength(product))
            {
                mLength[product] = length(a) + length(b) + 1 ;
                mExpression[product] = toString(a) + "^" + toString(b) ;
            }
        }
    }

    for (long a = 2 ; a <= iSqrtNumber ; ++a)
    {
        long product = a * a ;
        for (long b = 2 ; product <= lNumber ; ++b , product *= a)
        {
            long div = lNumber / product ;
            long mod = lNumber % product ;

            size_t curLength ;
            if (div != 1) curLength = getLength(div) + getLength(product) + 1 ;
            else curLength = getLength(div * product) ;
            if (mod != 0) curLength += getLength(mod) + 1 ;

            if (curLength < szNumberLength)
            {
                string curExpression ;
                if (div != 1) curExpression = getExpression(div) + "*" + getExpression(product) ;
                else curExpression = getExpression(div * product) ;
                if (mod != 0) curExpression = curExpression + "+" + getExpression(mod) ;

                szNumberLength = curLength ;
                strNumber = curExpression ;
            }
        }
    }

    cout << strNumber << "\n" ;

    return 0 ;
}


#include<bits/stdc++.h>
#define ll long long
#define int long long
using namespace std;
void qmax(int &x,int y) {if (x<y) x=y;}
void qmin(int &x,int y) {if (x>y) x=y;}
long long read()
{
    char s;
    long long k=0,base=1;
    while((s=getchar())!='-'&&s!=EOF&&!(isdigit(s)));
	if(s=='-')base=-1,s=getchar();
    while(isdigit(s)){k=k*10+(s^'0');s=getchar();}
    return k*base;
}
void write(int x)
{
    if(x<0){putchar('-');write(-x);}
    else{if(x/10)write(x/10);putchar(x%10+'0');}
}
ll n,len,s;
string E;
char CH[20],A[20];
int LEN[1100000];
map<ll,string> Map;
map<ll,ll> ma;

map<ll,string>::iterator it1;
int chai(ll x)
{
    if (x<=1000000) return LEN[x];
    int s1=0;
    while (x)
    {
        s1++;
        x/=10;
    }
    return s1;
}
void work1()
{
    LEN[0]=1;
    ll x=1;
    for (int i=1;i<=6;i++)
    {
        for (ll j=x;j<x*10;j++) LEN[j]=i;
        x*=10;
    }
    LEN[1000000]=7;
    //预处理长度
    for (int i=2;i<100000;i++)
    {
        ll s=i,l1=LEN[i],s1,s2;
        for (ll j=2;;j++)
        {
            if (s*i>10000000000ll)break;
            if (LEN[i]+1+LEN[j]>5) break;
            s=s*i;
            ll &y=ma[s];
            if ((y==0&&(LEN[i]+1+LEN[j]<chai(s)))||(LEN[i]+1+LEN[j]<y))
            {
                y=LEN[i]+1+LEN[j];
                sprintf(CH,"%lld^%lld",i,j);
                Map[s]=CH;
            }

            s1=s+s;s2=2;int L233=0;
            while (s1<=10000000000ll)
            {
                L233=LEN[i]+2+LEN[j]+chai(s2);
                if (L233>5) break;
                ll &y=ma[s1];
                if ((y==0&&(L233<chai(s1)))||(L233<y))
                {
                    y=L233;
                    sprintf(CH,"%lld*%lld^%lld",s2,i,j);
                    Map[s1]=CH;
                }
                s2++;s1=s1+s;
            }
        }
    }
}
int work(ll x)
{
    if (x<=1000||(ma.count(x))) return chai(x);
    return len=ma[x];
}
ll a,b,c,d,S,sum,aa,B,C,D,ans;
signed main()
{
#ifdef ylx
    freopen("991F.in","r",stdin);
    freopen("991F.out","w",stdout);
#endif
    n=read();
    if (n<=1000)
    {
		cout<<n;
        return 0;
    }
    work1();
    if (ma.count(n))
    {
        cout<<Map[n];
        return 0;
    }
    it1=Map.begin();
    ans=chai(n);
    sprintf(A,"%lld",n);char CH2[30];
    while (it1!=Map.end())
    {
        ll &it2=ma[it1->first];
        if ((it1->first)>n) break;
        s=n-(it1->first);
        if (n%it1->first==0)
        {
            s=n;
            if (it2+chai((s/it1->first))+1<ans)
            {
                ans=it2+(s/it1->first)+1;
                for (int i=0;i<it2;i++) CH[i]=(it1->second)[i];CH[it2]='\0';
                sprintf(A,"%lld*%s",s/it1->first,CH);
            }
            it1++;
            continue;
        }
        if (ma.count(s)&&ma[s]!=0)
        {
            if (it2+ma[s]<ans)
            {
                ans=ma[s]+it2;
                for (int i=0;i<it2;i++) CH[i]=(it1->second)[i];CH[it2]='\0';
				string Y=Map[s];
				ll ss=ma[s];
				for (int i=0;i<ss;i++) CH2[i]=Y[i];CH2[ss]='\0';
                sprintf(A,"%s+%s",CH,CH2);
            }
        } else
        {
            if (it2+chai(s)<ans)
            {
                ans=chai(s)+it2;
                for (int i=0;i<it2;i++) CH[i]=(it1->second)[i];
                CH[it2]='\0';
                sprintf(A,"%s+%lld",CH,s);
            }
        }
        it1++;
    }

    ll A1=ans;
//  return 0;
    ans=chai(n);
    sum=1;S=0;
    for (b=2;b<=100000;b++)
    {
        sum=1;
        if (b>n) break;
        for (c=1;c<=65;c++)
        {
            if (sum>n/b) break;
            sum=sum*b;
            a=n/sum;
            d=n%(a*sum);
            S=0;
//          sum=sum*b;
            S=chai(b);
            if (a!=1) S+=1+chai(a);
            if (c!=1) S+=1+chai(c);
            if (d!=0) S+=1+chai(d);
//          if (b==10) cerr<<a<<"*"<<b<<"^"<<c<<"+"<<d<<" "<<sum<<" "<<ans<<" "<<s<<" \n";
            if (S<ans)
            {
                aa=a,B=b,C=c,D=d;
                ans=S;
            }
        }
    }
//  cerr<<"\n"<<A<<" "<<B<<" "<<C<<" "<<D<<" \n";
    if (A1<=ans)
    {
        printf("%s",A);
        return 0;
    }
    if (!(aa||B||C||D))
    {
        cout<<n;return 0;
    }
    if (aa!=1)
    {
        cout<<aa<<"*";
    }
    cout<<B;
    if (C!=1) cout<<"^"<<C;
    if (D!=0) cout<<"+"<<D;

    return 0;
}


#include<bits/stdc++.h>
#define ll long long
#define int long long
using namespace std;
void qmax(int &x,int y) {if (x<y) x=y;}
void qmin(int &x,int y) {if (x>y) x=y;}
long long read()
{
    char s;
    long long k=0,base=1;
    while((s=getchar())!='-'&&s!=EOF&&!(isdigit(s)));
	if(s=='-')base=-1,s=getchar();
    while(isdigit(s)){k=k*10+(s^'0');s=getchar();}
    return k*base;
}
void write(int x)
{
    if(x<0){putchar('-');write(-x);}
    else{if(x/10)write(x/10);putchar(x%10+'0');}
}
ll n,len,s;
string E;
char CH[20],A[20];
int LEN[1100000];
map<ll,string> Map;
map<ll,ll> ma;

map<ll,string>::iterator it1;
int chai(ll x)
{
    if (x<=1000000) return LEN[x];
    int s1=0;
    while (x)
    {
        s1++;
        x/=10;
    }
    return s1;
}
void work1()
{
    LEN[0]=1;
    ll x=1;
    for (int i=1;i<=6;i++)
    {
        for (ll j=x;j<x*10;j++) LEN[j]=i;
        x*=10;
    }
    LEN[1000000]=7;
    //预处理长度
    for (int i=2;i<100000;i++)
    {
        ll s=i,l1=LEN[i],s1,s2;
        for (ll j=2;;j++)
        {
            if (s*i>10000000000ll)break;
            if (LEN[i]+1+LEN[j]>5) break;
            s=s*i;
            ll &y=ma[s];
            if ((y==0&&(LEN[i]+1+LEN[j]<chai(s)))||(LEN[i]+1+LEN[j]<y))
            {
                y=LEN[i]+1+LEN[j];
                sprintf(CH,"%lld^%lld",i,j);
                Map[s]=CH;
            }

            s1=s+s;s2=2;int L233=0;
            while (s1<=10000000000ll)
            {
                L233=LEN[i]+2+LEN[j]+chai(s2);
                if (L233>5) break;
                ll &y=ma[s1];
                if ((y==0&&(L233<chai(s1)))||(L233<y))
                {
                    y=L233;
                    sprintf(CH,"%lld*%lld^%lld",s2,i,j);
                    Map[s1]=CH;
                }
                s2++;s1=s1+s;
            }
        }
    }
}
int work(ll x)
{
    if (x<=1000||(ma.count(x))) return chai(x);
    return len=ma[x];
}
ll a,b,c,d,S,sum,aa,B,C,D,ans;
signed main()
{
#ifdef ylx
    freopen("991F.in","r",stdin);
    freopen("991F.out","w",stdout);
#endif
    n=read();
    if (n<=1000)
    {
		cout<<n;
        return 0;
    }
    work1();
    if (ma.count(n))
    {
        cout<<Map[n];
        return 0;
    }
    it1=Map.begin();
    ans=chai(n);
    sprintf(A,"%lld",n);char CH2[30];
    while (it1!=Map.end())
    {
        ll &it2=ma[it1->first];
        if ((it1->first)>n) break;
        s=n-(it1->first);
        if (n%it1->first==0)
        {
            s=n;
            if (it2+chai((s/it1->first))+1<ans)
            {
                ans=it2+(s/it1->first)+1;
                for (int i=0;i<it2;i++) CH[i]=(it1->second)[i];CH[it2]='\0';
                sprintf(A,"%lld*%s",s/it1->first,CH);
            }
            it1++;
            continue;
        }
        if (ma.count(s))
        {
            if (it2+ma[s]<ans)
            {
                ans=ma[s]+it2;
                for (int i=0;i<it2;i++) CH[i]=(it1->second)[i];CH[it2]='\0';
				string Y=Map[s];
				ll ss=ma[s];
				for (int i=0;i<ss;i++) CH2[i]=Y[i];CH2[ss]='\0';
                sprintf(A,"%s+%s",CH,CH2);
            }
        } else
        {
            if (it2+chai(s)<ans)
            {
                ans=chai(s)+it2;
                for (int i=0;i<it2;i++) CH[i]=(it1->second)[i];
                CH[it2]='\0';
                sprintf(A,"%s+%lld",CH,s);
            }
        }
        it1++;
    }

    ll A1=ans;
//  return 0;
    ans=chai(n);
    sum=1;S=0;
    for (b=2;b<=100000;b++)
    {
        sum=1;
        if (b>n) break;
        for (c=1;c<=65;c++)
        {
            if (sum>n/b) break;
            sum=sum*b;
            a=n/sum;
            d=n%(a*sum);
            S=0;
//          sum=sum*b;
            S=chai(b);
            if (a!=1) S+=1+chai(a);
            if (c!=1) S+=1+chai(c);
            if (d!=0) S+=1+chai(d);
//          if (b==10) cerr<<a<<"*"<<b<<"^"<<c<<"+"<<d<<" "<<sum<<" "<<ans<<" "<<s<<" \n";
            if (S<ans)
            {
                aa=a,B=b,C=c,D=d;
                ans=S;
            }
        }
    }
//  cerr<<"\n"<<A<<" "<<B<<" "<<C<<" "<<D<<" \n";
    if (A1<=ans)
    {
        printf("%s",A);
        return 0;
    }
    if (!(aa||B||C||D))
    {
        cout<<n;return 0;
    }
    if (aa!=1)
    {
        cout<<aa<<"*";
    }
    cout<<B;
    if (C!=1) cout<<"^"<<C;
    if (D!=0) cout<<"+"<<D;

    return 0;
}


#include<bits/stdc++.h>
#define ll long long
#define int long long
using namespace std;
void qmax(int &x,int y) {if (x<y) x=y;}
void qmin(int &x,int y) {if (x>y) x=y;}
long long read()
{
    char s;
    long long k=0,base=1;
    while((s=getchar())!='-'&&s!=EOF&&!(isdigit(s)));
	if(s=='-')base=-1,s=getchar();
    while(isdigit(s)){k=k*10+(s^'0');s=getchar();}
    return k*base;
}
void write(int x)
{
    if(x<0){putchar('-');write(-x);}
    else{if(x/10)write(x/10);putchar(x%10+'0');}
}
ll n,len,s;
string E;
char CH[20],A[20];
int LEN[1100000];
map<ll,string> Map;
map<ll,ll> ma;

map<ll,string>::iterator it1;
int chai(ll x)
{
    if (x<=1000000) return LEN[x];
    int s1=0;
    while (x)
    {
        s1++;
        x/=10;
    }
    return s1;
}
void work1()
{
    LEN[0]=1;
    ll x=1;
    for (int i=1;i<=6;i++)
    {
        for (ll j=x;j<x*10;j++) LEN[j]=i;
        x*=10;
    }
    LEN[1000000]=7;
    //预处理长度
    for (int i=2;i<100000;i++)
    {
        ll s=i,l1=LEN[i],s1,s2;
        for (ll j=2;;j++)
        {
            if (s*i>10000000000ll)break;
            if (LEN[i]+1+LEN[j]>5) break;
            s=s*i;
            ll &y=ma[s];
            if ((y==0&&(LEN[i]+1+LEN[j]<chai(s)))||(LEN[i]+1+LEN[j]<y))
            {
                y=LEN[i]+1+LEN[j];
                sprintf(CH,"%lld^%lld",i,j);
                Map[s]=CH;
            }

            s1=s+s;s2=2;int L233=0;
            while (s1<=10000000000ll)
            {
                L233=LEN[i]+2+LEN[j]+chai(s2);
                if (L233>5) break;
                ll &y=ma[s1];
                if ((y==0&&(L233<chai(s1)))||(L233<y))
                {
                    y=L233;
                    sprintf(CH,"%lld*%lld^%lld",s2,i,j);
                    Map[s1]=CH;
                }
                s2++;s1=s1+s;
            }
        }
    }
}
int work(ll x)
{
    if (x<=1000||(!ma.count(x)||ma[x]==0)) return chai(x);
    return len=ma[x];
}
ll a,b,c,d,S,sum,aa,B,C,D,ans;
signed main()
{
#ifdef ylx
    freopen("991F.in","r",stdin);
    freopen("991F.out","w",stdout);
#endif
    n=read();
    if (n<=1000)
    {
		cout<<n;
        return 0;
    }
    work1();
    if (ma.count(n))
    {
        cout<<Map[n];
        return 0;
    }
    it1=Map.begin();
    ans=chai(n);
    sprintf(A,"%lld",n);char CH2[30];
    while (it1!=Map.end())
    {
        ll &it2=ma[it1->first];
        if ((it1->first)>n) break;
        s=n-(it1->first);
        if (n%it1->first==0)
        {
            s=n;
			ll T=s/it1->first;
            if (it2+work(T)+1<ans)
            {
				if (!ma.count(T)||ma[T]==0)
				{
               		ans=it2+chai(T)+1;
              		for (int i=0;i<it2;i++) CH[i]=(it1->second)[i];CH[it2]='\0';
             	   	sprintf(A,"%lld*%s",s/it1->first,CH);
				} else
				{
					ans=it2+work(T)+1;
              		for (int i=0;i<it2;i++) CH[i]=(it1->second)[i];CH[it2]='\0';
					string Y=Map[T];
					ll ss=ma[T];
					for (int i=0;i<ss;i++) CH2[i]=Y[i];CH2[ss]='\0';
             	   	sprintf(A,"%s*%s",CH2,CH);
				}
            }
            it1++;
            continue;
        }
        if (ma.count(s)&&ma[s]!=0)
        {
            if (it2+ma[s]<ans)
            {
                ans=ma[s]+it2;
                for (int i=0;i<it2;i++) CH[i]=(it1->second)[i];CH[it2]='\0';
				string Y=Map[s];
				ll ss=ma[s];
				for (int i=0;i<ss;i++) CH2[i]=Y[i];CH2[ss]='\0';
                sprintf(A,"%s+%s",CH,CH2);
            }
        } else
        {
            if (it2+chai(s)<ans)
            {
                ans=chai(s)+it2;
                for (int i=0;i<it2;i++) CH[i]=(it1->second)[i];
                CH[it2]='\0';
                sprintf(A,"%s+%lld",CH,s);
            }
        }
        it1++;
    }

    ll A1=ans;
//  return 0;
    ans=chai(n);
    sum=1;S=0;
    for (b=2;b<=100000;b++)
    {
        sum=1;
        if (b>n) break;
        for (c=1;c<=65;c++)
        {
            if (sum>n/b) break;
            sum=sum*b;
            a=n/sum;
            d=n%(a*sum);
            S=0;
            S=chai(b);
            if (a!=1)
			{
				S+=1+work(a);
			}
            if (c!=1) S+=1+chai(c);
            if (d!=0) S+=1+chai(d);
            if (S<ans)
            {
				if (ma.count(a)&&ma[a]!=0)
				{
					int X=ma[a];
					string y=Map[a];
					for (int i=0;i<X;i++) CH[i]=y[i];CH[X]='\0';
				} else
				{
					sprintf(CH,"%d",a);
				}
                aa=a,B=b,C=c,D=d;
                ans=S;
            }
        }
    }
    if (A1<=ans)
    {
        printf("%s",A);
        return 0;
    }
    if (!(aa||B||C||D))
    {
        cout<<n;return 0;
    }
    if (aa!=1)
    {
		cout<<CH<<"*";
    }
    cout<<B;
    if (C!=1) cout<<"^"<<C;
    if (D!=0) cout<<"+"<<D;
    return 0;
}


#include<bits/stdc++.h>
#define ll long long
#define int long long
using namespace std;
void qmax(int &x,int y) {if (x<y) x=y;}
void qmin(int &x,int y) {if (x>y) x=y;}
long long read()
{
    char s;
    long long k=0,base=1;
    while((s=getchar())!='-'&&s!=EOF&&!(isdigit(s)));
    if(s==EOF)exit(0);if(s=='-')base=-1,s=getchar();
    while(isdigit(s)){k=k*10+(s^'0');s=getchar();}
    return k*base;
}
void write(int x)
{
    if(x<0){putchar('-');write(-x);}

    else{if(x/10)write(x/10);putchar(x%10+'0');}
}
ll n,len,s;
string E;
char CH[20],A[20];
int LEN[1100000];
map<ll,string> Map;
map<ll,ll> ma;

map<ll,string>::iterator it1;
int chai(ll x)
{
    if (x<=1000000) return LEN[x];
    int s1=0;
    while (x)
    {
        s1++;
        x/=10;
    }
    return s1;
}
void work1()
{
    LEN[0]=1;
    ll x=1;
    for (int i=1;i<=6;i++)
    {
        for (ll j=x;j<x*10;j++) LEN[j]=i;
        x*=10;
    }
    LEN[1000000]=7;
    //预处理长度
    for (int i=2;i<100000;i++)
    {
        ll s=i,l1=LEN[i],s1,s2;
        for (ll j=2;;j++)
        {
            if (s*i>10000000000ll)break;
            if (LEN[i]+1+LEN[j]>5) break;
            s=s*i;
            ll &y=ma[s];
            if ((y==0&&(LEN[i]+1+LEN[j]<chai(s)))||(LEN[i]+1+LEN[j]<y))
            {
                y=LEN[i]+1+LEN[j];
                sprintf(CH,"%lld^%lld",i,j);
                Map[s]=CH;
            }

            s1=s+s;s2=2;int L233=0;
            while (s1<=10000000000ll)
            {
                L233=LEN[i]+2+LEN[j]+chai(s2);
                if (L233>5) break;
                ll &y=ma[s1];
                if ((y==0&&(L233<chai(s1)))||(L233<y))
                {
                    y=L233;
                    sprintf(CH,"%d*%lld^%lld",s2,i,j);
                    Map[s1]=CH;
                }
                s2++;s1=s1+s;
            }
        }
    }
}
int work(ll x)
{
    if (x<=1000||(ma.count(x))) return chai(x);
    return len=ma[x];
}
ll a,b,c,d,S,sum,aa,B,C,D,ans;
signed main()
{
#ifdef ylx
    freopen("991F.in","r",stdin);
    freopen("991F.out","w",stdout);
#endif
    n=read();
    if (n<=1000)
    {
        printf("%d\n",n);
        return 0;
    }
    work1();
    if (ma[n]!=0)
    {
        cout<<Map[n];
        return 0;
    }
    it1=Map.begin();
    ans=chai(n);
    sprintf(A,"%lld",n);char CH2[30];
    while (it1!=Map.end())
    {
        ll &it2=ma[it1->first];
        if ((it1->first)>n) break;
        s=n-(it1->first);
        if (n%it1->first==0)
        {
            s=n;
            if (it2+chai((s/it1->first))+1<ans)
            {
                ans=it2+(s/it1->first)+1;
                for (int i=0;i<it2;i++) CH[i]=(it1->second)[i];CH[it2]='\0';
                sprintf(A,"%d*%s",s/it1->first,CH);
            }
            it1++;
            continue;
        }
        if (ma.count(s))
        {
            if (it2+ma[s]<ans)
            {
                ans=ma[s]+it2;
                for (int i=0;i<it2;i++) CH[i]=(it1->second)[i];CH[it2]='\0';
				string Y=Map[s];
				ll ss=ma[s];
				for (int i=0;i<ss;i++) CH2[i]=Y[i];CH2[ss]='\0';
                sprintf(A,"%s+%s",CH,CH2);
            }
        } else
        {
            if (it2+chai(s)<ans)
            {
                ans=chai(s)+it2;
                for (int i=0;i<it2;i++) CH[i]=(it1->second)[i];
                CH[it2]='\0';
                sprintf(A,"%s+%lld",CH,s);
            }
        }
        it1++;
    }

    ll A1=ans;
//  return 0;
    ans=chai(n);
    sum=1;S=0;
    for (b=2;b<=100000;b++)
    {
        sum=1;
        if (b>n) break;
        for (c=1;c<=65;c++)
        {
            if (sum>n/b) break;
            sum=sum*b;
            a=n/sum;
            d=n%(a*sum);
            S=0;
//          sum=sum*b;
            S=chai(b);
            if (a!=1) S+=1+chai(a);
            if (c!=1) S+=1+chai(c);
            if (d!=0) S+=1+chai(d);
//          if (b==10) cerr<<a<<"*"<<b<<"^"<<c<<"+"<<d<<" "<<sum<<" "<<ans<<" "<<s<<" \n";
            if (S<ans)
            {
                aa=a,B=b,C=c,D=d;
                ans=S;
            }
        }
    }
//  cerr<<"\n"<<A<<" "<<B<<" "<<C<<" "<<D<<" \n";
    if (A1<=ans)
    {
        printf("%s",A);
        return 0;
    }
    if (!(aa||B||C||D))
    {
        cout<<n;return 0;
    }
    if (aa!=1)
    {
        cout<<aa<<"*";
    }
    cout<<B;
    if (C!=1) cout<<"^"<<C;

    if (D!=0) cout<<"+"<<D;

    return 0;
}


#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
#include<map>
#include<queue>
#include<cmath>
#include<stack>
#include<set>
#define ll long long
#define maxn 200005
#define re register
#define inf 1e9
#define eps 1e-10
using namespace std;

inline int read()
{
	int x=0,w=1; char c=getchar();
	while(c<'0'||c>'9') {if(c=='-') w=-1; c=getchar();}
	while(c<='9'&&c>='0') {x=(x<<1)+(x<<3)+c-'0'; c=getchar();}
	return w==1?x:-x;
}

map<ll,string>Map;
map<ll,string>::iterator it;

inline string Get(ll x)
{
	string ans="";
	int s[13],cnt=0;
	while(x) {
		s[++cnt]=x%10;
		x/=10;
	}
	for(int i=cnt; i>=1; i--)ans+=char(s[i]+'0');
	return ans;
}

int main()
{
	ll n;
	scanf("%lld",&n);
	ll len=sqrt(n);
	for(ll i=2;i<=len;i++)
	{
		for(ll j=i*i,k=2;j<=n;j*=i,k++)
		{
			string gg=Get(i)+"^"+Get(k);
			if(gg.size()>=Get(j).size())continue;
			if(Map[j].size()==0) Map[j]=gg;
			else if(Map[j].size()>gg.size())Map[j]=gg;
		}
	}
	string ans=Get(n);
	for(it=Map.begin();it!=Map.end();it++)
	{
		ll k=(*it).first;
		string gg=(*it).second;
		if(n/k>=2)
		{
			gg+="*";
			gg+=(Map.count(n/k))?Map[n/k]:Get(n/k);
		}
		if(n%k)
		{
			gg+="+";
			gg+=(Map.count(n%k))?Map[n%k]:Get(n%k);
		}
		if(ans.size()>gg.size())ans=gg;
	}
	cout<<ans<<endl;
	return 0;
}


/**
 *    Author:  "Robin Singh" !!!!
**/
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(),(x).end()
#define ff first
#define ss second
#define mp make_pair
#define str string
#define szz(v) ((int)(v).size())
#define fr(i, j, k) for(int i = j; i < k; i++)     // 0 -> n-1 (i,0,n)
#define bk(i, j, k) for(int i = j-1; i >= k; i--)  // n-1 -> 0 (i,n,0)
#define frit(it, a) for(__typeof((a).begin()) it = a.begin(); it != a.end(); ++it)
#define mem(ptr)  memset(ptr, 0, sizeof ptr)  // use fill() for value other than 0 //
#define rtn return
#define itt(a)   __typeof((a).begin())
#define RT  (cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << " ms\n")  // Run Time
#define nl "\n"  // New Line
#define dbg(x) (cerr << #x << " = " << x << "  ")
#define enl (cerr << "\n")
#define dbgg(x,y) (cerr << #x << " = " << x << " -> " << #y << " = " << y << "\n")
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector< pair<int,int> > vpii;
typedef vector< pair<ll, ll> > vpll;
const long long mod = 1e9+7;
const ld eps = 1e-9;
const int inf = (1<<30);
const ll INF = (1LL<<61);

ll gcd(ll a,ll b) { return b==0 ? a : gcd(b, a%b); }
ll expo(ll x, ll y){ ll res = 1; x = x % mod;  while (y > 0) { if (y & 1)res = (res*x) % mod; y = y>>1;x = (x*x) % mod;}return res;}
void matmul(ll a[][2], ll b[][2]) { ll tmp[2][2]; for(int i=0; i<2; i++) { for(int j=0; j<2; j++) { tmp[i][j] = 0; for(int k=0; k<2; k++) tmp[i][j] = (tmp[i][j] + a[i][k]*b[k][j]) % mod; }} for(int i=0; i<2; i++) for(int j=0; j<2; j++) a[i][j] = tmp[i][j]; }
ll fibo(int n)    // returns nth fibonacci number, also S(n) = f(n+2)-1
{ if(n == 0) return 0; else if(n == 1) return 1; ll T[2][2] = { {0, 1} , {1, 1} }; ll res[2][2] = { {1, 0}, {0,1} }; n--; while(n) { if(n & 1) matmul(res, T); n >>= 1; matmul(T, T); } return res[1][1]; }

int main()
{
    ios_base::sync_with_stdio(false); cin.tie(0);
    ll n;
    cin >> n;
    if(n < 10000) cout << n;
    else{
        string s, t;
        ll sz, tmp, now = n;
        while(now >= 10000)
        {
        s = to_string(n);
        sz = s.size();
        sz--;
        if(s[0] > '1'){
            t += s[0];
            t += "*10^";
        }
        else t += "10^";
        t += to_string(sz);
        tmp = s[0]-'0';
        tmp = tmp*(pow(10LL, sz));
        now = n - tmp;
        if(now >= 10000)
            t += '+';
        }
        if(now >= 1){
            t += '+';
            t += (to_string(now));
        }
        cout << t;
    }
    return 0;
}


/**
 *    Author:  "Robin Singh" !!!!
**/
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(),(x).end()
#define ff first
#define ss second
#define mp make_pair
#define str string
#define szz(v) ((int)(v).size())
#define fr(i, j, k) for(int i = j; i < k; i++)     // 0 -> n-1 (i,0,n)
#define bk(i, j, k) for(int i = j-1; i >= k; i--)  // n-1 -> 0 (i,n,0)
#define frit(it, a) for(__typeof((a).begin()) it = a.begin(); it != a.end(); ++it)
#define mem(ptr)  memset(ptr, 0, sizeof ptr)  // use fill() for value other than 0 //
#define rtn return
#define itt(a)   __typeof((a).begin())
#define RT  (cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << " ms\n")  // Run Time
#define nl "\n"  // New Line
#define dbg(x) (cerr << #x << " = " << x << "  ")
#define enl (cerr << "\n")
#define dbgg(x,y) (cerr << #x << " = " << x << " -> " << #y << " = " << y << "\n")
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector< pair<int,int> > vpii;
typedef vector< pair<ll, ll> > vpll;
const long long mod = 1e9+7;
const ld eps = 1e-9;
const int inf = (1<<30);
const ll INF = (1LL<<61);

ll gcd(ll a,ll b) { return b==0 ? a : gcd(b, a%b); }
ll expo(ll x, ll y){ ll res = 1; x = x % mod;  while (y > 0) { if (y & 1)res = (res*x) % mod; y = y>>1;x = (x*x) % mod;}return res;}
void matmul(ll a[][2], ll b[][2]) { ll tmp[2][2]; for(int i=0; i<2; i++) { for(int j=0; j<2; j++) { tmp[i][j] = 0; for(int k=0; k<2; k++) tmp[i][j] = (tmp[i][j] + a[i][k]*b[k][j]) % mod; }} for(int i=0; i<2; i++) for(int j=0; j<2; j++) a[i][j] = tmp[i][j]; }
ll fibo(int n)    // returns nth fibonacci number, also S(n) = f(n+2)-1
{ if(n == 0) return 0; else if(n == 1) return 1; ll T[2][2] = { {0, 1} , {1, 1} }; ll res[2][2] = { {1, 0}, {0,1} }; n--; while(n) { if(n & 1) matmul(res, T); n >>= 1; matmul(T, T); } return res[1][1]; }

map <ll, string> m;
vector < pair<ll, string> > v;
const ll nn = 1e10 + 9;

string better(string x, string y){
    if(x.size() < y.size()) return x;
    else return y;
}

// generate all a^b
void brute(){
    for(ll i=2; i<=1e5; i++){
        int p=1;
        string s, t;
        for(ll j=i*i; j<nn; j=j*i){
            p++;
            s = (to_string(i) + "^" + to_string(p));
            if(m.find(j) != m.end()) t = m[j];
            else t = to_string(j);
            m[j] = better(s, t);
        }
    }
    for(auto it : m)
        v.push_back(it);
}

string need(ll x){
    if(x==0) return "";
    else if(m.count(x)) return ("+" + m[x]);
    else return ("+" + to_string(x));
}

int main()
{
    ios_base::sync_with_stdio(false); cin.tie(0);
    ll n;
    cin >> n;
    brute();
    string ans = to_string(n);
    int sz = v.size();
    int ind = sz-1;
    for(int i=0; i<sz; i++){
        bool yes = 0;
        string tmp;
        //a^b + need
        if(v[i].first <= n){
            tmp = v[i].second + need(n-v[i].first);
            ans = better(ans, tmp);
        }
        while(i <= ind){
            if(v[i].first * v[ind].first <= n){
                yes = 1;
                break;
            }
            ind--;
        }
        //a^b*c^d+need
        if(yes){
            tmp = v[i].second + "*" + v[ind].second;
            ll x = n - (v[i].ff * v[ind].ff);
            tmp += need(x);
            ans = better(ans, tmp);
        }
        //a^b*c + need
        // for each i we have to check all other indices whose product is <= n
        int j = ind-1;
        while(j>=i && v[i].first * v[j].first <= n){
            tmp = v[i].second + "*" + v[j].second;
            ll x = n - (v[i].ff * v[j].ff);
            tmp += need(x);
            ans = better(ans, tmp);
            j--;
        }
    }
    cout << ans;
    return 0;
}


/**
 *    Author:  "Robin Singh" !!!!
**/
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(),(x).end()
#define ff first
#define ss second
#define mp make_pair
#define str string
#define szz(v) ((int)(v).size())
#define fr(i, j, k) for(int i = j; i < k; i++)     // 0 -> n-1 (i,0,n)
#define bk(i, j, k) for(int i = j-1; i >= k; i--)  // n-1 -> 0 (i,n,0)
#define frit(it, a) for(__typeof((a).begin()) it = a.begin(); it != a.end(); ++it)
#define mem(ptr)  memset(ptr, 0, sizeof ptr)  // use fill() for value other than 0 //
#define rtn return
#define itt(a)   __typeof((a).begin())
#define RT  (cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << " ms\n")  // Run Time
#define nl "\n"  // New Line
#define dbg(x) (cerr << #x << " = " << x << "  ")
#define enl (cerr << "\n")
#define dbgg(x,y) (cerr << #x << " = " << x << " -> " << #y << " = " << y << "\n")
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector< pair<int,int> > vpii;
typedef vector< pair<ll, ll> > vpll;
const long long mod = 1e9+7;
const ld eps = 1e-9;
const int inf = (1<<30);
const ll INF = (1LL<<61);

ll gcd(ll a,ll b) { return b==0 ? a : gcd(b, a%b); }
ll expo(ll x, ll y){ ll res = 1; x = x % mod;  while (y > 0) { if (y & 1)res = (res*x) % mod; y = y>>1;x = (x*x) % mod;}return res;}
void matmul(ll a[][2], ll b[][2]) { ll tmp[2][2]; for(int i=0; i<2; i++) { for(int j=0; j<2; j++) { tmp[i][j] = 0; for(int k=0; k<2; k++) tmp[i][j] = (tmp[i][j] + a[i][k]*b[k][j]) % mod; }} for(int i=0; i<2; i++) for(int j=0; j<2; j++) a[i][j] = tmp[i][j]; }
ll fibo(int n)    // returns nth fibonacci number, also S(n) = f(n+2)-1
{ if(n == 0) return 0; else if(n == 1) return 1; ll T[2][2] = { {0, 1} , {1, 1} }; ll res[2][2] = { {1, 0}, {0,1} }; n--; while(n) { if(n & 1) matmul(res, T); n >>= 1; matmul(T, T); } return res[1][1]; }

map <ll, string> m;
vector < pair<ll, string> > v;

string better(string x, string y){
    if(x.size() < y.size()) return x;
    else return y;
}

// generate all a^b and choose shortest notation

void brute(){
    for(ll i=2; i<=1e5; i++){
        int p=1;
        string s, t;
        for(ll j=i; j<=1e10; j=j*i, p++){
            s = (to_string(i) + "^" + to_string(p));
            if(m.find(j) != m.end()) t = m[j];
            else t = to_string(j);
            m[j] = better(s, t);
        }
    }
    for(auto it : m)
        v.push_back(it);
}

string need(ll x){
    if(x==0) return "";
    else if(m.count(x)) return ("+" + m[x]);
    else return ("+" + to_string(x));
}

int main()
{
    ios_base::sync_with_stdio(false); cin.tie(0);
    ll n;
    cin >> n;
    brute();
    string ans = to_string(n);
    int sz = v.size();
    int ind = sz-1;
    for(int i=0; i<sz; i++){
        bool yes = 0;
        string tmp;
        //a^b + need
        if(v[i].first <= n){
            tmp = v[i].second + need(n-v[i].first);
            ans = better(ans, tmp);
        }
        while(i <= ind){
            if(v[i].first * v[ind].first <= n){
                yes = 1;
                break;
            }
            ind--;
        }
        //a^b*c^d+need
        if(yes){
            tmp = v[i].second + "*" + v[ind].second;
            ll x = n - (v[i].ff * v[ind].ff);
            tmp += need(x);
            ans = better(ans, tmp);
        }
        //a^b*c + need
        // for each i do we have to check all other indices whose product is <= n ?
        int j = ind-1;
 /*       while(j>=i && v[i].first * v[j].first <= n){
            tmp = v[i].second + "*" + v[j].second;
            ll x = n - (v[i].ff * v[j].ff);
            tmp += need(x);
            ans = better(ans, tmp);
            j--;
        } */
    }
    cout << ans;
    return 0;
}


#include <bits/stdc++.h>

#define x first
#define y second
#define mp make_pair
#define pb push_back
#define sqr(x) (x) * (x)
#define pii pair<int, int>
#define all(c) c.begin(), c.end()
#define sz(c) int((c).size())
#define forn(i, n) for(int i = 0; i < int(n); i++)

using namespace std;

typedef long long ll;
typedef long double ld;

const ll N = 2e5 + 100, M = 2e3 + 9, INF = 1e9 + 7;
const ld EPS = 1e-10;

int a[N], d[N];
vector<int> b;

int main()
{
    bool ok = false;
    ll i, j, k, n, m, f, t, cnt;
    cin >> n;
    forn(i, n)
        cin >> a[i];
    forn(i, n)
        if (a[i] % 10 == 0)
        {
            ok = false;
            forn(j, sz(b))
                if ((b[j] < 100 && b[j] > 9) && (a[i] < 100 && a[i] > 9) || a[i] == b[j])
                {
                    ok = true;
                    break;
                }
            if (ok)
                continue;
            b.pb(a[i]);
        }
    forn(i, n)
    {
        ok = false;
        forn(j, sz(b))
            if ((b[j] < 100 && b[j] > 9) && (a[i] < 100 && a[i] > 9) || a[i] == b[j])
            {
                ok = true;
                break;
            }
        if (ok)
            continue;
        b.pb(a[i]);
        break;
    }
    cout << sz(b) << endl;
    forn(i, sz(b))
    cout << b[i] << ' ';
    return 0;
}


#include <bits/stdc++.h>

#define x first
#define y second
#define mp make_pair
#define pb push_back
#define sqr(x) (x) * (x)
#define pii pair<int, int>
#define all(c) c.begin(), c.end()
#define sz(c) int((c).size())
#define forn(i, n) for(int i = 0; i < int(n); i++)

using namespace std;

typedef long long ll;
typedef long double ld;

const ll N = 2e5 + 100, M = 2e3 + 9, INF = 1e9 + 7;
const ld EPS = 1e-10;

int a[N], d[N];
vector<int> b;

int main()
{
    bool ok = false;
    ll i, j, k, n, m, f, t, cnt;
    cin >> n;
    forn(i, n)
        cin >> a[i];
    k = 0;
    forn(i, n)
        d[i] = -1;
    forn(i, n)
    {
        m = a[i];
        cnt = 0;
        if (!m)
            ok = true;
        while (m % 10 == 0 && m > 0)
        {
            m /= 10;
            cnt++;
        }
        if (m < 10 && m > 0)
        {
            if (d[cnt] == -1)
                d[cnt] = a[i], k++;
        }
    }
    if (ok)
        d[k++] = 0;
    if (k == 1 && d[0])
        k = 0;
    cout << k << endl;
    forn(i, k)
        cout << d[i] << ' ';
    return 0;
}


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

int main()
{
    int n;
    while ( cin >> n )
    {
        int cnt1 = 0;
        int cnt2 = 0;
        int a;
        vector<int>v;
        int ret1 = 1;
        int ret2 = 1;
        int ret3 = 1;
        int temp;
        for(int i = 0; i < n; i++ )
        {
			scanf("%d",&a);
			if ( a == 0|| a == 100 ) {
                v.push_back(a);
            }
			else if ( a < 10 && ret1)
            {
                ret1 = 0;
                v.push_back(a);
            }
			else if ( a%10 == 0 && ret2 )
            {
                ret2 = 0;
                v.push_back(a);
            }
            else {
            	ret3 = 0;
                temp = a;
            }
        }

        v.push_back(temp);
        int size = v.size();
        sort(v.begin(), v.end());
        cout << size << endl;
        for(int i = 0; i < size; i++ )
        {
            if ( i )printf(" ");
            printf("%d", v[i]);
        }
        printf("\n");
    }
    return 0;
}


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

int main()
{
    int n;
    while ( cin >> n )
    {
        int cnt1 = 0;
        int cnt2 = 0;
        int a;
        vector<int>v;
        int ret1 = 0;
        int ret2 = 0;
        int temp;
        for(int i = 0; i < n; i++ )
        {
			scanf("%d",&a);
			if ( a == 0|| a == 100 ) {
                v.push_back(a);
            }
			else if ( a < 10 && ret1 == 0)
            {
                ret1 = 1;
                v.push_back(a);
            }
			else if ( a%10 == 0 && ret2 == 0)
            {
                ret2 = 1;
                v.push_back(a);
            }
            else {
                temp = a;
            }
        }
		if ( !ret1 && !ret2 && temp)
    	{
			v.push_back(temp);
		}
        int size = v.size();
        sort(v.begin(), v.end());
        cout << size << endl;
        for(int i = 0; i < size; i++ )
        {
            if ( i )printf(" ");
            printf("%d", v[i]);
        }
        printf("\n");
    }
    return 0;
}


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

int main()
{
    int n;
    while ( cin >> n )
    {
        int cnt1 = 0;
        int cnt2 = 0;
        int a;
        vector<int>v;
        int ret1 = 1;
        int ret2 = 1;
        int ret3 = 1;
        int temp;
        for(int i = 0; i < n; i++ )
        {
			scanf("%d",&a);
			if ( a == 0|| a == 100 ) {
                v.push_back(a);
            }
			else if ( a < 10 && ret1)
            {
                ret1 = 0;
                v.push_back(a);
            }
			else if ( a%10 == 0 && ret2 )
            {
                ret2 = 0;
                v.push_back(a);
            }
            else {
            	ret3 = 0;
                temp = a;
            }
        }
        if ( ret1 && ret2 )
        {
            v.push_back(temp);
        }
        int size = v.size();
        sort(v.begin(), v.end());
        cout << size << endl;
        for(int i = 0; i < size; i++ )
        {
            if ( i )printf(" ");
            printf("%d", v[i]);
        }
        printf("\n");
    }
    return 0;
}


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

int main()
{
    int n;
    while ( cin >> n )
    {
        int cnt1 = 0;
        int cnt2 = 0;
        int a;
        vector<int>v;
        int ret1 = 1;
        int ret2 = 1;
        int ret3 = 1;
        int temp;
        for(int i = 0; i < n; i++ )
        {
			scanf("%d",&a);
			if ( a == 0|| a == 100 ) {
                v.push_back(a);
            }
			else if ( a < 10 && ret1)
            {
                ret1 = 0;
                v.push_back(a);
            }
			else if ( a%10 == 0 && ret2 )
            {
                ret2 = 0;
                v.push_back(a);
            }
            else {
            	ret3 = 0;
                temp = a;
            }
        }
        if ( ret1 && ret2 && ret3 )
        {
            v.push_back(temp);
        }
        int size = v.size();
        sort(v.begin(), v.end());
        cout << size << endl;
        for(int i = 0; i < size; i++ )
        {
            if ( i )printf(" ");
            printf("%d", v[i]);
        }
        printf("\n");
    }
    return 0;
}


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

int main()
{
    int n;
    while ( cin >> n )
    {
        int cnt1 = 0;
        int cnt2 = 0;
        int a;
        vector<int>v;
        v.clear();
        int ret1 = 0;
        int ret2 = 0;
        int temp;
        for(int i = 0; i < n; i++ )
        {
			scanf("%d",&a);
			if ( a == 0|| a == 100 ) {
                v.push_back(a);
            }
			else if ( a < 10 && ret1 == 0)
            {
                ret1 = 1;
                v.push_back(a);
            }
			else if ( a%10 == 0 && ret2 == 0)
            {
                ret2 = 1;
                v.push_back(a);
            }
            else {
                temp = a;
            }
        }
		if ( !ret1 && !ret2 && temp)
    	{
			v.push_back(temp);
		}
        int size = v.size();
        cout << size << endl;
        for(int i = 0; i < size; i++ )
        {
            if ( i )printf(" ");
            printf("%d", v[i]);
        }
        printf("\n");
    }
    return 0;
}


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

int main()
{
    int n;
    while ( cin >> n )
    {
        int cnt1 = 0;
        int cnt2 = 0;
        int a;
        vector<int>v;
        v.clear();
        int ret1 = 0;
        int ret2 = 0;
        int temp = 0;
        for(int i = 0; i < n; i++ )
        {
			scanf("%d",&a);
			if ( !a|| a == 100 ) {
                v.push_back(a);
            }
			else if ( a < 10 && ret1 == 0)
            {
                ret1 = 1;
                v.push_back(a);
            }
			else if ( a%10 == 0 && ret2 == 0)
            {
                ret2 = 1;
                v.push_back(a);
            }
            else {
                temp = a;
            }
        }
		if ( !ret1 && !ret2 && temp)
    	{
			v.push_back(temp);
		}
        int size = v.size();
        cout << size << endl;
        for(int i = 0; i < size; i++ )
        {
            if ( i )printf(" ");
            printf("%d", v[i]);
        }
        printf("\n");
    }
    return 0;
}


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

int main()
{
    int n;
    while ( cin >> n )
    {
        int cnt1 = 0;
        int cnt2 = 0;
        int a;
        vector<int>v;
        int ret1 = 1;
        int ret2 = 1;
        int ret3 = 1;
        int temp;
        for(int i = 0; i < n; i++ )
        {
			scanf("%d",&a);
			if ( a == 0|| a == 100 ) {
                v.push_back(a);
            }
			else if ( a < 10 && ret1)
            {
                ret1 = 0;
                v.push_back(a);
            }
			else if ( a%10 == 0 && ret2 )
            {
                ret2 = 0;
                v.push_back(a);
            }
            else {
            	ret3 = 0;
                temp = a;
            }
        }
        if ( ret1 && ret2 && ret3 )
        {
            v.push_back(temp);
        }
        int size = v.size();
        sort(v.begin(), v.end());
        for(int i = 0; i < size; i++ )
        {
            if ( i )printf(" ");
            printf("%d", v[i]);
        }
        printf("\n");
    }
    return 0;
}


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

int main()
{
    int n;
    while ( cin >> n )
    {
        int cnt1 = 0;
        int cnt2 = 0;
        int a;
        vector<int>v;
        int ret1 = 0;
        int ret2 = 0;
        int temp;
        for(int i = 0; i < n; i++ )
        {
			scanf("%d",&a);
			if ( a == 0|| a == 100 ) {
                v.push_back(a);
            }
			else if ( a < 10 && ret1 == 0)
            {
                ret1 = 1;
                v.push_back(a);
            }
			else if ( a%10 == 0 && ret2 == 0)
            {
                ret2 = 1;
                v.push_back(a);
            }
            else {
                temp = a;
            }
        }
		if ( !ret1 && !ret2 && temp)
        	v.push_back(temp);
        int size = v.size();
        sort(v.begin(), v.end());
        cout << size << endl;
        for(int i = 0; i < size; i++ )
        {
            if ( i )printf(" ");
            printf("%d", v[i]);
        }
        printf("\n");
    }
    return 0;
}


#include <stdio.h>
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <cstring>
#include <vector>
#include <math.h>
#include <queue>
#include <map>
#include <algorithm>
#define N 500005
#define mod 1000000009

#define C(x) memset(x, -1, sizeof(x))
#define go(i,n,m) for(int i=n; i<=m; i++)
#define down(i,n,m) for(int i=n; i>=m; i--)

using namespace std;

typedef long long ll;
void gt(int &a, int b){ if (a < b) a = b; }
string n2s(int a){ stringstream ss; ss << a; return ss.str(); }
typedef pair<int, int> pi;
string getKey(int v, int h){ return n2s(v)+ "-" + n2s(h);}
/**
 Use cases && constrains
    only sume 2 numbers, 1 have 0
    give k numbers
    => find maximum numbers he can chose => sum any two from those numbers

    INPUT
        n(1->100)
        n integer d(0->100)

 Idea
    output k numbers
        k-1 number have 0, the other number don't have

        ans
        add_no_zero = true
        1->n
            read temp
            temp have 0 => add
            else add_no_zero
                    add
                    add_no_zero = false
 Complexity

 Test
 3
 2  70 3

 2
 2  70
 */

vector<int> ans;
int mark[N]{0};
int main() {
//    freopen("/Users/Tom/Program/algo/programming_challenge/data/input.txt", "rt", stdin);
    int n;
    bool add_no_zero = true;
    cin >> n;
    while(n--){
        int temp;
        cin >> temp;
        if(temp == 0 || temp == 100 || temp%10 ==0){
            if(mark[temp]) continue;
            ans.push_back(temp);
            mark[temp] = 1;
        } else if(add_no_zero){
            ans.push_back(temp);
            add_no_zero = false;
        }
    }
    if(ans.size() < 2){
        cout << 0;
        return 0;
    }

    cout << ans.size() << endl;
    go(i,0,ans.size()-1) cout << ans[i] << " ";
    return 0;
}


#include <stdio.h>
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <cstring>
#include <vector>
#include <math.h>
#include <queue>
#include <map>
#include <algorithm>
#define N 500005
#define mod 1000000009

#define C(x) memset(x, -1, sizeof(x))
#define go(i,n,m) for(int i=n; i<=m; i++)
#define down(i,n,m) for(int i=n; i>=m; i--)

using namespace std;

typedef long long ll;
void gt(int &a, int b){ if (a < b) a = b; }
string n2s(int a){ stringstream ss; ss << a; return ss.str(); }
typedef pair<int, int> pi;
string getKey(int v, int h){ return n2s(v)+ "-" + n2s(h);}
/**
 Use cases && constrains
    only sume 2 numbers, 1 have 0
    give k numbers
    => find maximum numbers he can chose => sum any two from those numbers

    INPUT
        n(1->100)
        n integer d(0->100)

 Idea
    output k numbers
        k-1 number have 0, the other number don't have

        ans
        add_no_zero = true
        1->n
            read temp
            temp have 0 => add
            else add_no_zero
                    add
                    add_no_zero = false
 Complexity

 Test
 3
 2  70 3

 2
 2  70
 */

vector<int> ans;
int main() {
//    freopen("/Users/Tom/Program/algo/programming_challenge/data/input.txt", "rt", stdin);
    int n;
    bool add_no_zero = true;
    cin >> n;
    while(n--){
        int temp;
        cin >> temp;
        if(temp%10 ==0){
            ans.push_back(temp);
        } else if(add_no_zero){
            ans.push_back(temp);
            add_no_zero = false;
        }
    }
    if(ans.size() < 2){
        cout << 0;
        return 0;
    }

    cout << ans.size() << endl;
    go(i,0,ans.size()-1) cout << ans[i] << " ";
    return 0;
}


#include <stdio.h>
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <cstring>
#include <vector>
#include <math.h>
#include <queue>
#include <map>
#include <algorithm>
#define N 500005
#define mod 1000000009

#define C(x) memset(x, -1, sizeof(x))
#define go(i,n,m) for(int i=n; i<=m; i++)
#define down(i,n,m) for(int i=n; i>=m; i--)

using namespace std;

typedef long long ll;
void gt(int &a, int b){ if (a < b) a = b; }
string n2s(int a){ stringstream ss; ss << a; return ss.str(); }
typedef pair<int, int> pi;
string getKey(int v, int h){ return n2s(v)+ "-" + n2s(h);}
/**
 Use cases && constrains
    only sume 2 numbers, 1 have 0
    give k numbers
    => find maximum numbers he can chose => sum any two from those numbers

    INPUT
        n(1->100)
        n integer d(0->100)

 Idea
    output k numbers
        000
        100
        a0
        ab0

        Priority
        100
        0
        a0
            have a0 find number < 10
            else find any number

 Complexity

 Test
 3
 2  70 3

 2
 2  70
 */

vector<int> ans;

int main() {
//    freopen("/Users/Tom/Program/algo/programming_challenge/data/input.txt", "rt", stdin);
    vector<int> ans;
    int n, x = -1, xo = -1, xy=-1;
    cin >> n;
    go(i,1,n){
        int temp;
        cin >> temp;
        if(temp == 0 || temp == 100) ans.push_back(temp);
        else if(temp<10) x = temp;
        else if(temp%10 == 0) xo = temp;
        else xy = temp;
    }
    if (xo != -1){
        ans.push_back(xo);
        if(x!=-1) ans.push_back(x);
    } else {
        if(x!=-1) ans.push_back(x);
        else if(xy!=-1) ans.push_back(xy);
    }

    cout << ans.size() << endl;
    for(int i:ans) cout << i << " ";

    return 0;
}


#include <stdio.h>
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <cstring>
#include <vector>
#include <math.h>
#include <queue>
#include <map>
#include <algorithm>
#define N 500005
#define mod 1000000009

#define C(x) memset(x, -1, sizeof(x))
#define go(i,n,m) for(int i=n; i<=m; i++)
#define down(i,n,m) for(int i=n; i>=m; i--)

using namespace std;

typedef long long ll;
void gt(int &a, int b){ if (a < b) a = b; }
string n2s(int a){ stringstream ss; ss << a; return ss.str(); }
typedef pair<int, int> pi;
string getKey(int v, int h){ return n2s(v)+ "-" + n2s(h);}
/**
 Use cases && constrains
    only sume 2 numbers, 1 have 0
    give k numbers
    => find maximum numbers he can chose => sum any two from those numbers

    INPUT
        n(1->100)
        n integer d(0->100)

 Idea
    output k numbers
        k-1 number have 0, the other number don't have

        ans
        add_no_zero = true
        1->n
            read temp
            temp have 0 => add
            else add_no_zero
                    add
                    add_no_zero = false
 Complexity

 Test
 3
 2  70 3

 2
 2  70
 */

vector<int> ans;
int main() {
//    freopen("/Users/Tom/Program/algo/programming_challenge/data/input.txt", "rt", stdin);
    int n;
    bool add_no_zero = true;
    cin >> n;
    while(n--){
        int temp;
        cin >> temp;
        if(temp == 0 || temp == 100 || temp%10 ==0){
            ans.push_back(temp);
        } else if(add_no_zero){
            ans.push_back(temp);
            add_no_zero = false;
        }
    }
    if(ans.size() < 2){
        cout << 0;
        return 0;
    }

    cout << ans.size() << endl;
    go(i,0,ans.size()-1) cout << ans[i] << " ";
    return 0;
}


#include <stdio.h>
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <cstring>
#include <vector>
#include <math.h>
#include <queue>
#include <map>
#include <algorithm>
#define N 500005
#define mod 1000000009

#define C(x) memset(x, -1, sizeof(x))
#define go(i,n,m) for(int i=n; i<=m; i++)
#define down(i,n,m) for(int i=n; i>=m; i--)

using namespace std;

typedef long long ll;
void gt(int &a, int b){ if (a < b) a = b; }
string n2s(int a){ stringstream ss; ss << a; return ss.str(); }
typedef pair<int, int> pi;
string getKey(int v, int h){ return n2s(v)+ "-" + n2s(h);}
/**
 Use cases && constrains
    only sume 2 numbers, 1 have 0
    give k numbers
    => find maximum numbers he can chose => sum any two from those numbers

    INPUT
        n(1->100)
        n integer d(0->100)

 Idea
    output k numbers
        k-1 number have 0, the other number don't have

        ans
        add_no_zero = true
        1->n
            read temp
            temp have 0 => add
            else add_no_zero
                    add
                    add_no_zero = false
 Complexity

 Test
 3
 2  70 3

 2
 2  70
 */

vector<int> ans;
int main() {
//    freopen("/Users/Tom/Program/algo/programming_challenge/data/input.txt", "rt", stdin);
    int n;
    bool add_no_zero = true;
    cin >> n;
    while(n--){
        int temp;
        cin >> temp;
        if(temp == 0 || temp == 100 || temp%10 ==0){
            ans.push_back(temp);
        } else if(add_no_zero){
            ans.push_back(temp);
            add_no_zero = false;
        }
    }
    cout << ans.size() << endl;
    go(i,0,ans.size()-1) cout << ans[i] << " ";
    return 0;
}


#include <stdio.h>
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <cstring>
#include <vector>
#include <math.h>
#include <queue>
#include <map>
#include <algorithm>
#define N 500005
#define mod 1000000009

#define C(x) memset(x, -1, sizeof(x))
#define go(i,n,m) for(int i=n; i<=m; i++)
#define down(i,n,m) for(int i=n; i>=m; i--)

using namespace std;

typedef long long ll;
void gt(int &a, int b){ if (a < b) a = b; }
string n2s(int a){ stringstream ss; ss << a; return ss.str(); }
typedef pair<int, int> pi;
string getKey(int v, int h){ return n2s(v)+ "-" + n2s(h);}
/**
 Use cases && constrains
    only sume 2 numbers, 1 have 0
    give k numbers
    => find maximum numbers he can chose => sum any two from those numbers

    INPUT
        n(1->100)
        n integer d(0->100)

 Idea
    output k numbers
        k-1 number have 0, the other number don't have

        ans
        add_no_zero = true
        1->n
            read temp
            temp have 0 => add
            else add_no_zero
                    add
                    add_no_zero = false
 Complexity

 Test
 3
 2  70 3

 2
 2  70
 */

vector<int> ans;

bool hasZero(int a){
    if (a == 0) return false;
    if (a < 10) return true;
    return a%10 == 0 || hasZero(a/10);
}

int main() {
//    freopen("/Users/Tom/Program/algo/programming_challenge/data/input.txt", "rt", stdin);
    int n;
    bool add_no_zero = true;
    cin >> n;
    while(n--){
        int temp;
        cin >> temp;
        if(hasZero(temp)){
            ans.push_back(temp);
        } else if(add_no_zero){
            ans.push_back(temp);
            add_no_zero = false;
        }
    }
    if(ans.size() < 2){
        cout << 0;
        return 0;
    }

    cout << ans.size() << endl;
    go(i,0,ans.size()-1) cout << ans[i] << " ";
    return 0;
}


#include <stdio.h>
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <cstring>
#include <vector>
#include <math.h>
#include <queue>
#include <map>
#include <algorithm>
#define N 500005
#define mod 1000000009

#define C(x) memset(x, -1, sizeof(x))
#define go(i,n,m) for(int i=n; i<=m; i++)
#define down(i,n,m) for(int i=n; i>=m; i--)

using namespace std;

typedef long long ll;
void gt(int &a, int b){ if (a < b) a = b; }
string n2s(int a){ stringstream ss; ss << a; return ss.str(); }
typedef pair<int, int> pi;
string getKey(int v, int h){ return n2s(v)+ "-" + n2s(h);}
/**
 Use cases && constrains
    only sume 2 numbers, 1 have 0
    give k numbers
    => find maximum numbers he can chose => sum any two from those numbers

    INPUT
        n(1->100)
        n integer d(0->100)

 Idea
    output k numbers
        k-1 number have 0, the other number don't have

        ans
        add_no_zero = true
        1->n
            read temp
            temp have 0 => add
            else add_no_zero
                    add
                    add_no_zero = false
 Complexity

 Test
 3
 2  70 3

 2
 2  70
 */

vector<int> ans;

bool hasZero(int a){
    if (a == 0) return true;
    if (a < 10) return false;
    return a%10 == 0 || hasZero(a/10);
}

int main() {
//    freopen("/Users/Tom/Program/algo/programming_challenge/data/input.txt", "rt", stdin);
    int n;
    bool add_no_zero = true;
    cin >> n;
    while(n--){
        int temp;
        cin >> temp;
        if(hasZero(temp)){
            ans.push_back(temp);
        } else if(add_no_zero){
            ans.push_back(temp);
            add_no_zero = false;
        }
    }
    if(ans.size() < 2){
        cout << 0;
        return 0;
    }

    cout << ans.size() << endl;
    go(i,0,ans.size()-1) cout << ans[i] << " ";
    return 0;
}


#include <stdio.h>
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <cstring>
#include <vector>
#include <math.h>
#include <queue>
#include <map>
#include <algorithm>
#define N 500005
#define mod 1000000009

#define C(x) memset(x, -1, sizeof(x))
#define go(i,n,m) for(int i=n; i<=m; i++)
#define down(i,n,m) for(int i=n; i>=m; i--)

using namespace std;

typedef long long ll;
void gt(int &a, int b){ if (a < b) a = b; }
string n2s(int a){ stringstream ss; ss << a; return ss.str(); }
typedef pair<int, int> pi;
string getKey(int v, int h){ return n2s(v)+ "-" + n2s(h);}
/**
 Use cases && constrains
    only sume 2 numbers, 1 have 0
    give k numbers
    => find maximum numbers he can chose => sum any two from those numbers

    INPUT
        n(1->100)
        n integer d(0->100)

 Idea
    output k numbers
        k-1 number have 0, the other number don't have

        ans
        add_no_zero = true
        1->n
            read temp
            temp have 0 => add
            else add_no_zero
                    add
                    add_no_zero = false
 Complexity

 Test
 3
 2  70 3

 2
 2  70
 */

vector<int> ans;
int main() {
    freopen("/Users/Tom/Program/algo/programming_challenge/data/input.txt", "rt", stdin);
    int n;
    bool add_no_zero = true;
    cin >> n;
    while(n--){
        int temp;
        cin >> temp;
        if(temp%10 ==0){
            ans.push_back(temp);
        } else if(add_no_zero){
            ans.push_back(temp);
            add_no_zero = false;
        }
    }
    if(ans.size() < 2){
        cout << 0;
        return 0;
    }

    cout << ans.size() << endl;
    go(i,0,ans.size()-1) cout << ans[i] << " ";
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define pii pair<int,int>
#define pdd pair<double,double>

typedef long long ll;

long double const PI = acosl(-1);
const int INF=1E9 + 4;
const int MAXN=2e5 + 123;
const long double EPS = 3e-16;
const ll MOD=1e9 + 7;
int binpow (int a, int n) {
	int res = 1;
	while (n) {
		if (n & 1)
			res *= a;
		a *= a;
		n >>= 1;
	}
	return res;
}
bool isv(char a){ return (a == 'a' ||a == 'A'|| a == 'E'|| a=='I'|| a == 'O'|| a == 'U' || a=='Y' || a == 'e' || a == 'i' || a=='o' || a == 'u' || a=='y');}
ll a[MAXN];
int b[MAXN];
void solve(){
	int n;
	cin >> n;
	for(int i = 0; i < n; i++) cin >> a[i];
	sort(a, a + n);
	vector<int>v;
	for(int i = 0; i < n; i++){
		int k = a[i];
		int j = 0;
		while(k > 0){
			j++;
			k = k /10;
		}
		if(j > 1 && a[i] % 10 != 0) continue;
		if(b[j])continue;
		b[j] = a[i];
		v.pb(a[i]);
	}
	if(v.size() == 0){ cout << 1 << endl << a[0];return;}
	cout << v.size() << endl;
	for(int x : v) cout << x << ' ';
}
int main() {
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	ios_base::sync_with_stdio(false);
     cin.tie(NULL);
     cout.tie(NULL);
	int t = 1;
   // cin >> t;
	while(t--) solve();
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define pii pair<int,int>
#define pdd pair<double,double>

typedef long long ll;

long double const PI = acosl(-1);
const int INF=1E9 + 4;
const int MAXN=2e5 + 123;
const long double EPS = 3e-16;
const ll MOD=1e9 + 7;
int binpow (int a, int n) {
	int res = 1;
	while (n) {
		if (n & 1)
			res *= a;
		a *= a;
		n >>= 1;
	}
	return res;
}
bool isv(char a){ return (a == 'a' ||a == 'A'|| a == 'E'|| a=='I'|| a == 'O'|| a == 'U' || a=='Y' || a == 'e' || a == 'i' || a=='o' || a == 'u' || a=='y');}
ll a[MAXN];
int b[MAXN];
void solve(){
	int n;
	cin >> n;
	for(int i = 0; i < n; i++) cin >> a[i];
	sort(a, a + n);
	vector<int>v;
	for(int i = 0; i < n; i++){
		int k = a[i];
		int j = 0;
		while(k > 0){
			j++;
			k = k /10;
		}
		if(b[j])continue;
		b[j] = a[i];
		v.pb(a[i]);
	}
	cout << v.size() << endl;
	for(int x : v) cout << x << ' ';
}
int main() {
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	ios_base::sync_with_stdio(false);
     cin.tie(NULL);
     cout.tie(NULL);
	int t = 1;
   // cin >> t;
	while(t--) solve();
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define pii pair<int,int>
#define pdd pair<double,double>

typedef long long ll;

long double const PI = acosl(-1);
const int INF=1E9 + 4;
const int MAXN=2e5 + 123;
const long double EPS = 3e-16;
const ll MOD=1e9 + 7;
int binpow (int a, int n) {
	int res = 1;
	while (n) {
		if (n & 1)
			res *= a;
		a *= a;
		n >>= 1;
	}
	return res;
}
bool isv(char a){ return (a == 'a' ||a == 'A'|| a == 'E'|| a=='I'|| a == 'O'|| a == 'U' || a=='Y' || a == 'e' || a == 'i' || a=='o' || a == 'u' || a=='y');}
ll a[MAXN];
int b[MAXN];
void solve(){
	int n;
	cin >> n;
	for(int i = 0; i < n; i++) cin >> a[i];
	sort(a, a + n);
	vector<int>v;
	for(int i = 0; i < n; i++){
		int k = a[i];
		int j = 0;
		while(k > 0){
			j++;
			k = k /10;
		}
		if(!b[j] || (j > 1 && a[i] % 10 == 0)){
		b[j] = a[i];
		v.pb(a[i]);}
	}
	cout << v.size() << endl;
	for(int x : v) cout << x << ' ';
}
int main() {
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	ios_base::sync_with_stdio(false);
     cin.tie(NULL);
     cout.tie(NULL);
	int t = 1;
   // cin >> t;
	while(t--) solve();
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define pii pair<int,int>
#define pdd pair<double,double>

typedef long long ll;

long double const PI = acosl(-1);
const int INF=1E9 + 4;
const int MAXN=2e5 + 123;
const long double EPS = 3e-16;
const ll MOD=1e9 + 7;
int binpow (int a, int n) {
	int res = 1;
	while (n) {
		if (n & 1)
			res *= a;
		a *= a;
		n >>= 1;
	}
	return res;
}
bool isv(char a){ return (a == 'a' ||a == 'A'|| a == 'E'|| a=='I'|| a == 'O'|| a == 'U' || a=='Y' || a == 'e' || a == 'i' || a=='o' || a == 'u' || a=='y');}
ll a[MAXN];
int b[MAXN];
void solve(){
	int n;
	cin >> n;
	for(int i = 0; i < n; i++) cin >> a[i];
	sort(a, a + n);
	vector<int>v;
	for(int i = 0; i < n; i++){
		int k = a[i];
		int j = 0;
		while(k > 0){
			j++;
			k = k /10;
		}
		if(j > 1 && a[i] % 10 != 0) continue;
		if(b[j])continue;
		b[j] = a[i];
		v.pb(a[i]);
	}
	cout << v.size() << endl;
	for(int x : v) cout << x << ' ';
}
int main() {
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	ios_base::sync_with_stdio(false);
     cin.tie(NULL);
     cout.tie(NULL);
	int t = 1;
   // cin >> t;
	while(t--) solve();
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define pii pair<int,int>
#define pdd pair<double,double>

typedef long long ll;

long double const PI = acosl(-1);
const int INF=1E9 + 4;
const int MAXN=2e5 + 123;
const long double EPS = 3e-16;
const ll MOD=1e9 + 7;
int binpow (int a, int n) {
	int res = 1;
	while (n) {
		if (n & 1)
			res *= a;
		a *= a;
		n >>= 1;
	}
	return res;
}
bool isv(char a){ return (a == 'a' ||a == 'A'|| a == 'E'|| a=='I'|| a == 'O'|| a == 'U' || a=='Y' || a == 'e' || a == 'i' || a=='o' || a == 'u' || a=='y');}
ll a[MAXN];
int b[MAXN];
bool fl,f;
void solve(){
	int n;
	cin >> n;
	int k = 0;
	int y = 0;
	for(int i = 0,x; i < n; i++){
		cin >> x;
		if(x == 0 || x == 100)a[++k] = x;
		else if(x < 10 && !f){a[++k] = x; f = 1;}
		else if(x % 10==0 && x >= 10 && !fl){a[++k] = x;fl = 1;}
		else y = x;
	}
	if(!fl && !f && y) a[++k] = y;
	cout << k << endl;
	for(int i = 1; i <= k; i++) cout << a[i] << ' ';
}
int main() {
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	ios_base::sync_with_stdio(false);
     cin.tie(NULL);
     cout.tie(NULL);
	int t = 1;
   // cin >> t;
	while(t--) solve();
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define pii pair<int,int>
#define pdd pair<double,double>

typedef long long ll;

long double const PI = acosl(-1);
const int INF=1E9 + 4;
const int MAXN=2e5 + 123;
const long double EPS = 3e-16;
const ll MOD=1e9 + 7;
int binpow (int a, int n) {
	int res = 1;
	while (n) {
		if (n & 1)
			res *= a;
		a *= a;
		n >>= 1;
	}
	return res;
}
bool isv(char a){ return (a == 'a' ||a == 'A'|| a == 'E'|| a=='I'|| a == 'O'|| a == 'U' || a=='Y' || a == 'e' || a == 'i' || a=='o' || a == 'u' || a=='y');}
ll a[MAXN];
int b[MAXN];
void solve(){
	int n;
	cin >> n;
	for(int i = 0; i < n; i++) cin >> a[i];
	if(n == 1){cout << n << endl << a[0];return;}
	sort(a, a + n);
	vector<int>v;
	for(int i = 0; i < n; i++){
		int k = a[i];
		int j = 0;
		while(k > 0){
			j++;
			k = k /10;
		}
		if(j > 1 && a[i] % 10 != 0) continue;
		if(b[j])continue;
		b[j] = a[i];
		v.pb(a[i]);
	}
	cout << v.size() << endl;
	for(int x : v) cout << x << ' ';
}
int main() {
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	ios_base::sync_with_stdio(false);
     cin.tie(NULL);
     cout.tie(NULL);
	int t = 1;
   // cin >> t;
	while(t--) solve();
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define pii pair<int,int>
#define pdd pair<double,double>

typedef long long ll;

long double const PI = acosl(-1);
const int INF=1E9 + 4;
const int MAXN=2e5 + 123;
const long double EPS = 3e-16;
const ll MOD=1e9 + 7;
int binpow (int a, int n) {
	int res = 1;
	while (n) {
		if (n & 1)
			res *= a;
		a *= a;
		n >>= 1;
	}
	return res;
}
bool isv(char a){ return (a == 'a' ||a == 'A'|| a == 'E'|| a=='I'|| a == 'O'|| a == 'U' || a=='Y' || a == 'e' || a == 'i' || a=='o' || a == 'u' || a=='y');}
ll a[MAXN];
int b[MAXN];
void solve(){
		int n;
	cin >> n;
	for(int i = 0; i < n; i++) cin >> a[i];
	sort(a, a + n);
	vector<int>v;
	for(int i = 0; i < n; i++){
		int k = a[i];
		int j = 0;
		while(k > 0){
			j++;
			k = k /10;
		}
		if(!b[j] || (j > 1 && a[i] % 10 == 0)){
		if(b[j] && b[j] % 10 == 0)continue;
		if(b[j]) v.erase(find(v.begin(),v.end(),b[j]));
		b[j] = a[i];
		v.pb(a[i]);
		}
	}
	cout << v.size() << endl;
	for(int x : v) cout << x << ' ';
}
int main() {
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	ios_base::sync_with_stdio(false);
     cin.tie(NULL);
     cout.tie(NULL);
	int t = 1;
   // cin >> t;
	while(t--) solve();
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main()
{
    int k,c=0;
    cin>>k;
    vector <int> v;
    for(int i=0;i<k;i++)
    {
        int di;
        cin>>di;
        if(di%10==0)
        v.push_back(di);
        else
        {
            if(c==0)
            {
                v.push_back(di);
                c++;
            }
        }
    }
    for(auto i=v.begin();i!=v.end();i++)
    cout<<*i<<" ";
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define L long long int
#define in(x) L x; cin>>x;
#define vi vector<L>
#define pb push_back
#define re(i,n) for(L i=1; i<=n; i++)
#define mp make_pair
#define pi(v) vector<pair<L,L>> v;
#define bi begin();3

bool sortinrev(const pair<int,int> &a,
               const pair<int,int> &b)
{
       return (a.first > b.first);
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
    in(k);
    string d;
    vector <L> s;
    L z=0,e=0,f=0;
    re(i,k){
    cin>>d;
    if(d.length()==1)
    {
        if(d=="0")
        s.pb(0);
        else if(z==0){
        s.pb(stoi(d));
        z=1;
        }
    }
    else if(d=="100" && e==0){
    s.pb(100);
    e=1;
    }
    else if(d.length()==2 && f==0)
    {
        if(stoi(d)%10==0){
        s.pb(stoi(d));
        f=1;
        }
    }
   // cout<<d.length()<<endl;
    }
    if(s.size()==0)
    cout<<"1"<<endl<<stoi(d);
    else{
    cout<<s.size()<<endl;
    for(L i=0;i<s.size();i++)
    cout<<s[i]<<" ";
    }
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define L long long int
#define in(x) L x; cin>>x;
#define vi vector<L>
#define pb push_back
#define re(i,n) for(L i=1; i<=n; i++)
#define mp make_pair
#define pi(v) vector<pair<L,L>> v;
#define bi begin();3

bool sortinrev(const pair<int,int> &a,
               const pair<int,int> &b)
{
       return (a.first > b.first);
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
    in(k);
    string d;
    vector <L> s;
    L z=0,e=0,f=0;
    re(i,k){
    cin>>d;
    if(d.length()==1)
    {
        if(d=="0")
        s.pb(0);
        else if(z==0){
        s.pb(stoi(d));
        z=1;
        }
    }
    else if(d=="100" && e==0){
    s.pb(100);
    e=1;
    }
    else if(d.length()==2 && f==0)
    {
        if(stoi(d)%10==0){
        s.pb(stoi(d));
        f=1;
        }
    }
   // cout<<d.length()<<endl;
    }
    cout<<s.size()<<endl;
    for(L i=0;i<s.size();i++)
    cout<<s[i]<<" ";
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main()
{
    int k,c=0;
    cin>>k;
    set <int> v;
    for(int i=0;i<k;i++)
    {
        int di;
        cin>>di;
        if(di%10==0)
        v.insert(di);
        else
        {
            if(c==0)
            {
                v.insert(di);
                c++;
            }
        }
    }

    for(auto i=v.begin();i!=v.end();i++)
    cout<<*i<<" ";
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define L long long int
#define in(x) L x; cin>>x;
#define vi vector<L>
#define pb push_back
#define re(i,n) for(L i=1; i<=n; i++)
#define mp make_pair
#define pi(v) vector<pair<L,L>> v;
#define bi begin();3

bool sortinrev(const pair<int,int> &a,
               const pair<int,int> &b)
{
       return (a.first > b.first);
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
    in(k);
    string d;
    vector <L> s;
    L z=0,e=0,f=0;
    if(k==1){
    cin>>d;
    cout<<"1"<<endl<<stoi(d);
    }
    else
    {
    re(i,k){
    cin>>d;
    if(d.length()==1)
    {
        if(d=="0")
        s.pb(0);
        else if(z==0){
        s.pb(stoi(d));
        z=1;
        }
    }
    else if(d=="100" && e==0){
    s.pb(100);
    e=1;
    }
    else if(d.length()==2 && f==0)
    {
        if(stoi(d)%10==0){
        s.pb(stoi(d));
        f=1;
        }
    }
   // cout<<d.length()<<endl;
    }
    cout<<s.size()<<endl;
    for(L i=0;i<s.size();i++)
    cout<<s[i]<<" ";
    }
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define L long long int
#define in(x) L x; cin>>x;
#define vi vector<L>
#define pb push_back
#define re(i,n) for(L i=1; i<=n; i++)
#define mp make_pair
#define pi(v) vector<pair<L,L>> v;
#define bi begin();3

bool sortinrev(const pair<int,int> &a,
               const pair<int,int> &b)
{
       return (a.first > b.first);
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
    in(k);
    string d;
    vector <L> s;
    L z=0,e=0,f=0;
    re(i,k){
    cin>>d;
    if(d.length()==1)
    {
        if(d=="0")
        s.pb(0);
        else if(z==0){
        s.pb(stoi(d));
        z=1;
        }
    }
    else if(d=="100" && e==0){
    s.pb(100);
    e=1;
    }
    else if(d.length()==2 && f==0)
    {
        if(stoi(d)%10==0){
        s.pb(stoi(d));
        f=1;
        }
    }
   // cout<<d.length()<<endl;
    }
    if(s.size()==0)
    cout<<stoi(d);
    else{
    cout<<s.size()<<endl;
    for(L i=0;i<s.size();i++)
    cout<<s[i]<<" ";
    }
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define L long long int
#define in(x) L x; cin>>x;
#define vi vector<L>
#define pb push_back
#define re(i,n) for(L i=0; i<n; i++)
#define mp make_pair
#define pi(v) vector<pair<L,L>> v;
#define bi begin();3

bool sortinrev(const pair<int,int> &a,
               const pair<int,int> &b)
{
       return (a.first > b.first);
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
    in(k);
    string d[k];
    vector <L> s;
    L z=0,e=0,f=0;
    re(i,k){
    cin>>d[i];
    if(d[i].length()==1)
    {
        if(d[i]=="0")
        s.pb(0);
        else if(z==0){
        s.pb(stoi(d[i]));
        z=1;
        }
    }
    else if(d[i]=="100" && e==0){
    s.pb(100);
    e=1;
    }
    else if(d[i].length()==2 && f==0)
    {
        if(stoi(d[i])%10==0){
        s.pb(stoi(d[i]));
        f=1;
        }
    }
   // cout<<d.length()<<endl;
    }
    if(e==1 && f==0 && z==0)
    {
       re(i,k)
       {
           if(d[i].length()==2)
           {
               s.pb(stoi(d[i]));
               break;
           }
       }
    }
    else if(e==0 && f==0 && z==0)
    {
        re(i,k)
        {
            if(d[i].length()==2)
            {
                s.pb(stoi(d[i]));
                break;
            }
        }
    }
    if(s.size()==0)
    cout<<"1"<<endl<<d[0];
    else{
    cout<<s.size()<<endl;
    for(L i=0;i<s.size();i++)
    cout<<s[i]<<" ";
    }
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main()
{
    int k,c=0;
    cin>>k;
    set <int> v;
    for(int i=0;i<k;i++)
    {
        int di;
        cin>>di;
        if(di%10==0)
        v.insert(di);
        else
        {
            if(c==0)
            {
                v.insert(di);
                c++;
            }
        }
    }
    cout<<v.size()<<endl;
    for(auto i=v.begin();i!=v.end();i++)
    cout<<*i<<" ";
    return 0;
}