Vasya is a regular participant at programming contests and is already experienced in finding important sentences in long statements. Of course, numbers constraints are important — factorization of a number less than 1000000 is easier than of a number less than 1000000000. However, sometimes it's hard to understand the number at the first glance. Could it be shortened? For example, instead of 1000000 you could write 10^{6}, instead of 1000000000 —10^{9}, instead of 1000000007 — 10^{9}+7.

Vasya decided that, to be concise, the notation should follow several rules: 

  * the notation should only consist of numbers, operations of addition ("+"), multiplication ("*") and exponentiation ("^"), in particular, the use of braces is forbidden; 
  * the use of several exponentiation operations in a row is forbidden, for example, writing "2^3^4" is unacceptable; 
  * the value of the resulting expression equals to the initial number; 
  * the notation should consist of the minimal amount of symbols. 



Given n, find the equivalent concise notation for it.

Input

The only line contains a single integer n (1 ≤ n ≤ 10 000 000 000).

Output

Output a concise notation of the number n. If there are several concise notations, output any of them.

Examples

Input

2018


Output

2018


Input

1000000007


Output

10^9+7


Input

10000000000


Output

100^5


Input

2000000000


Output

2*10^9

Note

The third sample allows the answer 10^10 also of the length 5.
#include <bits/stdc++.h>
using namespace std;
void qmax(long long &x, long long y) {
  if (x < y) x = y;
}
void qmin(long long &x, long long 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(long long x) {
  if (x < 0) {
    putchar('-');
    write(-x);
  } else {
    if (x / 10) write(x / 10);
    putchar(x % 10 + '0');
  }
}
long long n, len, s;
string E;
char CH[20], A[20];
long long LEN[1100000];
map<long long, string> Map;
map<long long, long long> ma;
map<long long, string>::iterator it1;
long long chai(long long x) {
  if (x <= 1000000) return LEN[x];
  long long s1 = 0;
  while (x) {
    s1++;
    x /= 10;
  }
  return s1;
}
void work1() {
  LEN[0] = 1;
  long long x = 1;
  for (long long i = 1; i <= 6; i++) {
    for (long long j = x; j < x * 10; j++) LEN[j] = i;
    x *= 10;
  }
  LEN[1000000] = 7;
  for (long long i = 2; i < 100000; i++) {
    long long s = i, l1 = LEN[i], s1, s2;
    for (long long j = 2;; j++) {
      if (s * i > 10000000000ll) break;
      if (LEN[i] + 1 + LEN[j] > 5) break;
      s = s * i;
      long long &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;
      long long L233 = 0;
      while (s1 <= 10000000000ll) {
        L233 = LEN[i] + 2 + LEN[j] + chai(s2);
        if (L233 > 5) break;
        long long &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;
      }
    }
  }
}
long long work(long long x) {
  if (x <= 1000 || (!ma.count(x) || ma[x] == 0)) return chai(x);
  return len = ma[x];
}
long long a, b, c, d, S, sum, aa, B, C, D, ans;
signed main() {
  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()) {
    long long &it2 = ma[it1->first];
    if ((it1->first) > n) break;
    s = n - (it1->first);
    if (n % it1->first == 0) {
      s = n;
      long long T = s / it1->first;
      if (it2 + work(T) + 1 < ans) {
        if (!ma.count(T) || ma[T] == 0) {
          ans = it2 + chai(T) + 1;
          for (long long 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 (long long i = 0; i < it2; i++) CH[i] = (it1->second)[i];
          CH[it2] = '\0';
          string Y = Map[T];
          long long ss = ma[T];
          for (long long 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 (long long i = 0; i < it2; i++) CH[i] = (it1->second)[i];
        CH[it2] = '\0';
        string Y = Map[s];
        long long ss = ma[s];
        for (long long 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 (long long i = 0; i < it2; i++) CH[i] = (it1->second)[i];
        CH[it2] = '\0';
        sprintf(A, "%s+%lld", CH, s);
      }
    }
    it1++;
  }
  long long A1 = ans;
  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) {
          long long X = ma[a];
          string y = Map[a];
          for (long long 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;
}
