Problem: A positive integer number n is written on a blackboard. It consists of not more than 105 digits. You have to transform it into a beautiful number by erasing some of the digits, and you want to erase as few digits as possible.

The number is called beautiful if it consists of at least one digit, doesn't have leading zeroes and is a multiple of 3. For example, 0, 99, 10110 are beautiful numbers, and 00, 03, 122 are not.

Write a program which for the given n will find a beautiful number such that n can be transformed into this number by erasing as few digits as possible. You can erase an arbitraty set of digits. For example, they don't have to go one after another in the number n.

If it's impossible to obtain a beautiful number, print -1. If there are multiple answers, print any of them.

Input

The first line of input contains n — a positive integer number without leading zeroes (1 ≤ n < 10100000).

Output

Print one number — any beautiful number obtained by erasing as few as possible digits. If there is no answer, print  - 1.

Examples

Input

1033


Output

33


Input

10


Output

0


Input

11


Output

-1

Note

In the first example it is enough to erase only the first digit to obtain a multiple of 3. But if we erase the first digit, then we obtain a number with a leading zero. So the minimum number of digits to be erased is two.

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
int inline in() {
  int x;
  scanf("%d", &x);
  return x;
}
long long inline lin() {
  long long x;
  scanf("%I64d", &x);
  return x;
}
void P(long long x) { printf("%I64d", x); }
void Pi(int x) { printf("%d", x); }
long long fx[] = {0, 0, -1, 1, -1, -1, 1, 1};
long long fy[] = {-1, 1, 0, 0, -1, 1, -1, 1};
long long bm(long long b, long long p) {
  long long namira;
  if (p == 0) return 1;
  if (p % 2 == 0) {
    namira = bm(b, p / 2);
    return ((namira % 1000000007) * (namira % 1000000007)) % 1000000007;
  } else {
    return ((b % 1000000007) * (bm(b, p - 1) % 1000000007)) % 1000000007;
  }
}
bool prm[1000007];
long long N = 1000000;
void sieve() {
  prm[1] = 1;
  for (long long i = 2; i <= sqrt(N); i++) {
    if (prm[i] == 0) {
      for (long long j = i + i; j <= N; j = j + i) prm[j] = 1;
    }
  }
}
long long gcd(long long a, long long b) {
  if (b == 0) {
    return a;
  } else
    return gcd(b, a % b);
}
long long lcm(long long a, long long b) { return (a * b) / gcd(a, b); }
queue<long long> q;
long long i, n, j, k, n1, a[300010], b[300010], ck[300010];
char s[300010];
long long level[300010];
bool vis[300010], par[300010];
vector<long long> V[300010];
map<long long, string> ss, r;
int main() {
  long long res;
  scanf("%s", &s);
  n = strlen(s);
  for (i = 0; i <= n - 1; i++) {
    a[i + 1] = s[i] - 48;
  }
  long long dd = 0;
  long long ans_ase = 0;
  for (i = 1; i <= n; i++) {
    if (a[i] == 0) {
      ck[i] = 1;
      ans_ase = 1;
    }
    a[i] = a[i] % 3;
    dd += a[i];
  }
  dd = dd % 3;
  long long now;
  for (i = 1; i <= n; i++) {
    if (ck[i] == 0) {
      now = i;
      break;
    }
  }
  for (i = now; i <= n; i++) {
    b[a[i]]++;
  }
  if (dd == 0) {
    long long now = 200000;
    for (i = 1; i <= n; i++) {
      if (ck[i] == 0) {
        now = i;
        break;
      }
    }
    if (now == 200000) {
      P((long long)0);
    } else {
      for (i = now; i <= n; i++) {
        printf("%c", s[i - 1]);
      }
    }
  } else if (dd == 1) {
    if (b[1] == 0) {
      if (b[2] >= 2) {
        if (b[2] == 2) {
          if (a[now] == 2) {
            long long pos;
            for (i = now + 1; i <= n; i++) {
              if (s[i - 1] - 48 > 0) {
                pos = i;
                break;
              }
            }
            if (a[pos] == 2) {
              long long pos1 = -1;
              for (i = pos + 1; i <= n; i++) {
                if (s[i - 1] - 48 > 0) {
                  pos1 = i;
                  break;
                }
              }
              if (pos1 == -1) {
                if (ans_ase) {
                  P((long long)0);
                } else {
                  P((long long)-1);
                }
              } else {
                for (i = pos1; i <= n; i++) {
                  printf("%c", s[i - 1]);
                }
              }
            } else {
              long long xxx = 0;
              printf("%c", s[pos - 1]);
              for (i = pos + 1; i <= n; i++) {
                if (xxx < 1 && a[i] == 2) {
                  xxx++;
                  continue;
                } else {
                  printf("%c", s[i - 1]);
                }
              }
            }
          } else {
            printf("%c", s[now - 1]);
            long long xx = 0;
            for (i = now + 1; i <= n; i++) {
              if (xx < 2 && a[i] == 2) {
                xx++;
                continue;
              } else {
                printf("%c", s[i - 1]);
              }
            }
          }
        } else {
          printf("%c", s[now - 1]);
          long long xx = 0;
          for (i = now + 1; i <= n; i++) {
            if (xx < 2 && a[i] == 2) {
              xx++;
              continue;
            } else {
              printf("%c", s[i - 1]);
            }
          }
        }
      } else {
        if (ans_ase) {
          P((long long)0);
        } else {
          P((long long)-1);
        }
      }
    } else {
      if (b[1] == 1 && a[now] == 1) {
        long long pos = -1;
        for (i = now + 1; i <= n; i++) {
          if (s[i - 1] - 48 > 0) {
            pos = i;
            break;
          }
        }
        if (pos == -1) {
          if (ans_ase) {
            P((long long)0);
          } else {
            P((long long)-1);
          }
          return 0;
        }
        long long max1 = n - pos + 1;
        if (b[2] >= 2) {
          long long xx = 0;
          long long max2 = n - now + 1 - 2;
          if (max1 >= max2) {
            for (i = pos; i <= n; i++) {
              printf("%c", s[i - 1]);
            }
            return 0;
          }
          printf("%c", s[now - 1]);
          for (i = now + 1; i <= n; i++) {
            if (xx < 2 && a[i] == 2) {
              xx++;
              continue;
            } else {
              printf("%c", s[i - 1]);
            }
          }
        } else {
          if (max1 > 0) {
            for (i = pos; i <= n; i++) {
              printf("%c", s[i - 1]);
            }
          } else if (ans_ase) {
            P((long long)0);
          } else {
            P((long long)-1);
          }
        }
      } else {
        long long xx = 0;
        printf("%c", s[now - 1]);
        for (i = now + 1; i <= n; i++) {
          if (a[i] == 1 && xx == 0) {
            xx = 1;
            continue;
          } else {
            printf("%c", s[i - 1]);
          }
        }
      }
    }
  } else {
    if (b[2] >= 1) {
      if (b[2] == 1) {
        if (a[now] == 2) {
          long long pos = -1;
          for (i = now + 1; i <= n; i++) {
            if (s[i - 1] - 48 > 0) {
              pos = i;
              break;
            }
          }
          if (pos == -1) {
            if (ans_ase) {
              P((long long)0);
            } else {
              P((long long)-1);
            }
            return 0;
          }
          long long max1 = n - pos + 1;
          if (b[1] >= 2) {
            long long max2 = n - now + 1 - 2;
            if (max1 >= max2) {
              for (i = pos; i <= n; i++) {
                printf("%c", s[i - 1]);
              }
              return 0;
            }
            printf("%c", s[now - 1]);
            long long xx = 0;
            for (i = now + 1; i <= n; i++) {
              if (a[i] == 1 && xx < 2) {
                xx++;
                continue;
              } else {
                printf("%c", s[i - 1]);
              }
            }
          } else {
            if (max1 > 0) {
              for (i = pos; i <= n; i++) {
                printf("%c", s[i - 1]);
              }
            } else {
              if (ans_ase) {
                P((long long)0);
              } else {
                P((long long)-1);
              }
            }
          }
        } else {
          printf("%c", s[now - 1]);
          long long xx = 0;
          for (i = now + 1; i <= n; i++) {
            if (a[i] == 2 && xx < 1) {
              xx++;
              continue;
            } else {
              printf("%c", s[i - 1]);
            }
          }
        }
      } else {
        printf("%c", s[now - 1]);
        long long xx = 0;
        for (i = now + 1; i <= n; i++) {
          if (a[i] == 2 && xx < 1) {
            xx++;
            continue;
          } else {
            printf("%c", s[i - 1]);
          }
        }
      }
    } else {
      if (b[1] >= 2) {
        if (b[1] == 2) {
          if (a[now] == 1) {
            long long pos;
            for (i = now + 1; i <= n; i++) {
              if (s[i - 1] - 48 > 0) {
                pos = i;
                break;
              }
            }
            if (a[pos] == 1) {
              long long pos1 = -1;
              for (i = pos + 1; i <= n; i++) {
                if (s[i - 1] - 48 > 0) {
                  pos1 = i;
                  break;
                }
              }
              if (pos1 == -1) {
                if (ans_ase) {
                  P((long long)0);
                } else {
                  P((long long)-1);
                }
              } else {
                for (i = pos1; i <= n; i++) {
                  printf("%c", s[i - 1]);
                }
              }
            } else {
              printf("%c", s[pos - 1]);
              long long xx = 0;
              for (i = pos + 1; i <= n; i++) {
                if (a[i] == 1 && xx < 1) {
                  xx++;
                  continue;
                } else {
                  printf("%c", s[i - 1]);
                }
              }
            }
          } else {
            printf("%c", s[now - 1]);
            long long xx = 0;
            for (i = now + 1; i <= n; i++) {
              if (a[i] == 1 && xx < 2) {
                xx++;
                continue;
              } else {
                printf("%c", s[i - 1]);
              }
            }
          }
        } else {
          printf("%c", s[now - 1]);
          long long xx = 0;
          for (i = now + 1; i <= n; i++) {
            if (a[i] == 1 && xx < 2) {
              xx++;
              continue;
            } else {
              printf("%c", s[i - 1]);
            }
          }
        }
      } else {
        if (ans_ase) {
          P((long long)0);
        } else {
          P((long long)-1);
        }
      }
    }
  }
  return 0;
}