function countSum(str) {

    var arr = str.split(''),
        sum = 0;

    for (var i = 0; i < arr.length; i++) {

        sum += parseInt(arr[i]);

    }

    return sum;

}

function classWatch() {

    var line = readline();
    var num = parseInt(line);
    var list = [];

    for (var i = num-(num.toString().length)*9; i < num; i++) {

        if (i + countSum(i.toString()) === num) {

            list.push(i);

        }

    }

    print(list.length);

    for (var j = 0; j < list.length; j++) {

        print(list[j]);

    }

}

classWatch();

var n = readline();
var len = n.toString().length;
function main(){
    var i = n;
    var numCounter = 0;
    var flag = n - len * 9;
    var numArr = [];
    for(i; i >= flag; i--){
        var subSum = 0;
        var numbers = i.toString().split('');
        numbers.forEach(element => {
            subSum += Number(element);
        });

        if(i+subSum == n){
            numCounter++
            numArr.unshift(i);
        }
    }
    print(numCounter);
    numArr.forEach(element => {
        print(element);
    });
}

main();

var firstLine = readline();

var rezult = findMagicNumbers(+firstLine.split(' ')[0]);

print(rezult.length);
rezult.forEach(function(num) {
  print(num);
})

function findMagicNumbers(inputValue) {

  function findSumOfDigits(num) {
    var digits = String(num)
      .split('')
      .map(function(digit) {
        return Number(digit);
      });

    var sumOfDigits = digits.reduce(function(sum, digit) {
      return sum + digit;
    }, 0);

    return sumOfDigits;
  }

  var numbers = [];

  for (var i = 1; i < 82; i++) {
    var current = inputValue - i;

    if (current <= 0) {
      continue;
    }

    var sum = findSumOfDigits(current);

    if (sum + current === inputValue) {
      numbers.push(current);
    }
  }

  return numbers.reverse();
}

var number = parseInt(readline());
var res = new Array;

for (var i = number - 1; i > number - 9*number.toString().length && i > 0; i--) {
    var temp = i
    var sum = 0;
    while (temp) {
        sum += temp % 10;
        temp = Math.floor(temp / 10);
    }

    if (sum + i === number) res.unshift(i);
}

print(res.length);
for (var i = 0; i < res.length; i++ ) print(res[i]);

'use strict';
var n = parseInt(readline());
var res = new Array;
var nLength = parseInt(n.toString().length);
var x = n - 9*nLength;
x = x > 0 ? x : 0;
    for (var i = x; i < n; i++) {
            var sum = 0, t = i;
                while (t) {
                    sum += t % 10;
                    t = Math.floor(t / 10);
                }
                if (sum + i === n)
                res.push(i);
            }
    print(res.length);
    for (var i = 0; i < res.length; i++)
        print(res[i]);

const
    num = readline()

var matches = 0,
    matchesValues = [];
    maxCharsSum = num.toString().length * 9,
    startValue = num - maxCharsSum < 0 ? 0 : num - maxCharsSum;
for (var i = startValue; i <= num; i++) {
    var tmpNum = i, sum = 0, tmp;

    while (tmpNum) {
        tmp = tmpNum % 10;
        tmpNum = (tmpNum - tmp) / 10;
        sum += tmp;
    }

    result = i + sum;
    if (result == num) {
        matches++;
        matchesValues.push(i);
    }
}

print(matches);
if (matches) {
    for (var j = 0; j < matchesValues.length; j++) {
        print(matchesValues[j]);
    }
}

function res(x){
    var i;
	var n = JSON.parse(x);
    var k = 0;
    var s = [];
    var m = [];
    s = n.toString().split('');
    n < 18 ? i = n : i = 9 * s.length;
    var p;
    while(i >= 0){
        var p = n - i;
        var t = p;
        while(p){
            t += (p % 10);
            p = Math.floor(p / 10);
        }
        if(t === n){
            m.push(n - i);
            k++;
        }
        i--;
    }
    print(k);
    for(var e of m)
    print(e);
}
res(readline());

function main() {
  var num = +readline();
  var numArray = [];
  var min = num - num.toString().length * 9;
  min = min > 0 ? min : 0;
  for (var i = min; i < num; i++) {
    var sum = i;
    var iStr = i.toString();
    for (var y = 0; y < iStr.length; y++) {
      sum += +iStr[y];
    }
    if (sum === num) numArray.push(i);
  }
  print(numArray.length);
  for (var j = 0; j < numArray.length; j++) {
    print(numArray[j]);
  }
}

main();

// http://codeforces.com/contest/875/submission/35182257

var n = parseInt(readline());
var minNumber = n - n.toString().length * 9;
var result = [];
for (var i = n; i > minNumber; i--) {
    if (i + getDigitsSum(i.toString()) === n) {
        result.unshift(i);
    }
}

print(result.length);
print(result.join(' '));

function getDigitsSum(num) {
    var result = 0;
    for (var i = 0; i < num.length; i++) {
        result += parseInt(num[i]);
    }
    return result;
}

var n=(readline());
var i,k=0;
var s=[],m=[];
s=n.split('');
n<18?i=n:i=9*s.length;
var p;
while(i>=0)
{
    p=n-i;
   var t=p;
   while(p)
{
    t+=(p%10);
    p=Math.floor(p/10);
}
if(t==n)
{
m.push(n-i);
k++;
}
i--;
}
print(k);
for(var e of m)
print(e);

var readline = readline();
//prompt("Enter Digit");
var n = +readline;
var resultToArray = [];
var j = 0;

if (n <= 101) {
  j = Math.floor(n / 1.7);
} else if (n <= 1001) {
  j = Math.floor(n / 1.4);
} else if (n <= 10001) {
  j = Math.floor(n / 1.3);
} else if (n <= 100001) {
  j = Math.floor(n / 1.2);
} else if (n <= 1000001) {
  j = Math.floor(n / 1.05);
} else if (n <= 10000001) {
  j = Math.floor(n / 1.025);
} else if (n <= 100000001) {
  j = Math.floor(n / 1.012);
} else if (n <= 1000000001) {
  j = Math.floor(n / 1.006);
}

for (var i = j; i < n; i++) {
  var tempVal = i,
    sumOfDigits = 0;
  while (tempVal) {
    sumOfDigits += tempVal % 10;
    tempVal = Math.floor(tempVal / 10);
  }
  var resultSum = i + sumOfDigits;
  if (resultSum === n) {
    resultToArray.push(i);
  }
}

print(resultToArray.length);
print(resultToArray.toString().replace(',', ' '));
    //console.log(resultToArray.length);
    //console.log(resultToArray.toString().replace(',', ' '));

var readline = readline();
//prompt("Enter Digit");
var n = +readline;
var resultToArray = [];
var j = 0;

if (n <= 101) {
  j = Math.floor(n / 1.7);
} else if (n <= 1001) {
  j = Math.floor(n / 1.4);
} else if (n <= 10001) {
  j = Math.floor(n / 1.3);
} else if (n <= 100001) {
  j = Math.floor(n / 1.2);
} else if (n <= 1000001) {
  j = Math.floor(n / 1.05);
} else if (n <= 10000001) {
  j = Math.floor(n / 1.025);
} else if (n <= 100000001) {
  j = Math.floor(n / 1.012);
} else if (n <= 1000000001) {
  j = Math.floor(n / 1.006);
}

for (var i = j; i < n; i++) {
  var tempVal = i,
    sumOfDigits = 0;
  while (tempVal) {
    sumOfDigits += tempVal % 10;
    tempVal = Math.floor(tempVal / 10);
  }
  var resultSum = i + sumOfDigits;
  if (resultSum === n) {
    resultToArray.push(i);
  }
}

print(resultToArray.length);
print(resultToArray.toString().replace(',', ' '));
    //console.log(resultToArrayay.length);
    //console.log(resultToArrayay.toString().replace(',', ' '));

function main() {
    var num = +readline();
    var Array = [];
    var min = num - num.toString().length * 9;
    min = min > 0 ? min : 0;
    for (var i = min; i < num; i++) {
        var sum = i;
        var iStr = i.toString();
        for (var j = 0; j < iStr.length; j++) {
            sum += +iStr[j];
        }
        if (sum === num) Array.push(i);
    }
    print(Array.length);
    for (var k = 0; k < Array.length; k++) {
        print(Array[k]);
    }
}

main();

var nStr = readline();
var n = +nStr;
var resultArr = [];
var j = 0;

if (n <= 101) {
  j = Math.floor(n / 1.7);
} else if (n <= 1001) {
  j = Math.floor(n / 1.4);
} else if (n <= 10001) {
  j = Math.floor(n / 1.3);
} else if (n <= 100001) {
  j = Math.floor(n / 1.2);
} else if (n <= 1000001) {
  j = Math.floor(n / 1.05);
} else if (n <= 10000001) {
  j = Math.floor(n / 1.025);
} else if (n <= 100000001) {
  j = Math.floor(n / 1.012);
} else if (n <= 1000000001) {
  j = Math.floor(n / 1.006);
}

for (var i = j; i < n; i++) {
  var tempI = i,
    sumOfDigits = 0;
  while (tempI) {
    sumOfDigits += tempI % 10;
    tempI = Math.floor(tempI / 10);
  }
  var resultSum = i + sumOfDigits;
  if (resultSum === n) {
    resultArr.push(i);
  }
}

print(resultArr.length);
print(resultArr.toString().replace(',', ' '));

var n=(readline());
var i,k=0;
var s=[],m=[];
if(n==1)
{
    m.push(n);
    k++;
}
s=n.split('');
s<9?i=n:i=9*s.length;
var p;
while(i>=0)
{
    p=n-i;
   var t=p;
   while(p)
{
    t+=(p%10);
    p=Math.floor(p/10);
}
if(t==n)
{
m.push(n-i);
k++;
}
i--;
}
print(k);
for(var e of m)
print(e);

function main() {
    var num = +readline();
    print('\n');
    var Array = [];
    var min = num - num.toString().length * 9;

    min = min > 0 ? min : 0;

    for (var i = min; i < num; i++) {
        var sum = i;
        var iStr = i.toString();
        for (var j = 0; j < iStr.length; j++) {
            sum += +iStr[j];
        }
        if (sum === num) Array.push(i);
    }

    print(Array.length);
    for (var k = 0; k < Array.length; k++) {
        print(Array[j]);
    }
}

main();

var n = parseInt(readline());

function getSum(number) {
    var sDigits = String(number).split('');
    var digits = sDigits.map(function(item) {
        return parseInt(item);
    })

    var result = digits.reduce(function(sum, current) {
        return sum + current;
    }, 0);

    return result;
}

function getRes() {
    var count = 0;
    for(var i = 10; i <=100; i++) {
        if((getSum(i) + i) == n) {
            count++;
            print(count);
            print(i);
        }

        else if(i==100 && count == 0) {
            print(0);
        }
    }
}

getRes();

var n = parseInt(readline());
print('\n');

function getSum(number) {
    var sDigits = String(number).split('');
    var digits = sDigits.map(function(item) {
        return parseInt(item);
    })

    var result = digits.reduce(function(sum, current) {
        return sum + current;
    }, 0);

    return result;
}

function getRes() {
    var count = 0;
    for(var i = 10; i <=100; i++) {
        if((getSum(i) + i) == n) {
            count++;
            print(count);
            print(i);
        }

        else if(i==100 && count == 0) {
            print(0);
        }
    }
}

getRes();

var n = parseInt(readline());
print('\n');

function getSum(number) {
    var sDigits = String(number).split('');
    var digits = sDigits.map(function(item) {
        return parseInt(item);
    })

    var result = digits.reduce(function(sum, current) {
        return sum + current;
    }, 0);

    return result;
}

function getRes() {
    var count = 0;
    for(var i = 0; i <=100; i++) {
        if((getSum(i) + i) == n) {
            count++;
            print(count);
            print(i);
        }

        else if(i==100 && count == 0) {
            print(0);
        }
    }
}

getRes();

function main() {
    var num = parseInt(readline());
    print('\n');
    var Array = [];
    var min = num - num.toString().length * 9;

    min = min > 0 ? min : 0;

    for (var i = min; i < num; i++) {
        var sum = i;
        var iStr = i.toString();
        for (var j = 0; j < iStr.length; j++) {
            sum += +iStr[j];
        }
        if (sum === num) Array.push(i);
    }

    print(Array.length);
    for (var k = 0; k < Array.length; k++) {
        print(Array[j]);
    }
}

main();

var firstLine = readline();
print('\n');

var args = firstLine.split(' ');

var count = 0;
var numRez = firstLine.split(' ')[0];
var res = [];

print(getRezult(numRez));
print(0);

function getRezult (num) {
  var input = `${num}`;
  var parse = [];
  var sum = 0;
  parse.push(+input);
  debugger;
  for (var i =0; i < input.length; i++) {
    parse.push(+input[i]);
  }

  for (var j =0; j < parse.length; j++) {
     sum += parse[j];
  }

  if(sum == numRez) {
    res.push(input);
  } else {
    count++;
  }

  if (count == numRez) {
    return 0;
  }
  getRezult(--input);

  return res;
}

var firstLine = readline();

var args = firstLine.split(' ');

var count = 0;
var numRez = firstLine.split(' ')[0];
var res = [];
const rezult = getRezult(numRez)

print(rezult.length);
print(rezult);

function getRezult (num) {
  var input = `${num}`;
  var parse = [];
  var sum = 0;
  parse.push(+input);
  debugger;
  for (var i =0; i < input.length; i++) {
    parse.push(+input[i]);
  }

  for (var j =0; j < parse.length; j++) {
     sum += parse[j];
  }

  if(sum == numRez) {
    res.push(input);
  } else {
    count++;
  }

  if (count == numRez) {
    return 0;
  }
  getRezult(--input);

  return res;
}

var firstLine = readline();

var args = firstLine.split(' ');

var count = 0;
var numRez = firstLine.split(' ')[0];
var res = [];
var rezult = getRezult(numRez)

print(rezult.length >= 0 ? rezult.length : '');
print(rezult);

function getRezult (num) {
  var input = `${num}`;
  var parse = [];
  var sum = 0;
  parse.push(+input);
  debugger;
  for (var i =0; i < input.length; i++) {
    parse.push(+input[i]);
  }

  for (var j =0; j < parse.length; j++) {
     sum += parse[j];
  }

  if(sum == numRez) {
    res.push(input);
  } else {
    count++;
  }

  if (count == numRez) {
    return 0;
  }
  return getRezult(--input);

  return res;
}

var firstLine = readline();

var rezult = findMagicNumbers(+firstLine.split(' ')[0]);

print(rezult.length);
print(rezult.join(' '));

function findMagicNumbers(inputValue) {
  var numbers = [];

  for (var i = 1; i < 82; i++) {
    var current = inputValue - i;
    var sum = ('' + current).split('').reduce((sumTemp, num) => sumTemp + num, 0);

    if (sum + current === inputValue) {
      number.push(sum);
    }
  }

  return numbers;
}

var firstLine = readline();

var rezult = findMagicNumbers(+firstLine.split(' ')[0]);

print(rezult.length);
print(rezult.join(' '));

function findMagicNumbers(inputValue) {

  function findSumOfDigits(num) {
    var digits = String(num)
      .split('')
      .map(function(digit) {
        return Number(digit);
      });

    var sumOfDigits = digits.reduce(function(sum, digit) {
      return sum + digit;
    }, 0);

    return sumOfDigits;
  }

  var numbers = [];

  for (var i = 1; i < 82; i++) {
    var current = inputValue - i;

    if (current <= 0) {
      continue;
    }

    var sum = findSumOfDigits(current);

    if (sum + current === inputValue) {
      numbers.push(current);
    }
  }

  return numbers;
}

var firstLine = readline();
print('\n');

var args = firstLine.split(' ');

var count = 0;
var numRez = firstLine.split(' ')[0];
var res = [];

print(res.legth, getRezult(numRez));

function getRezult (num) {
  var input = `${num}`;
  var parse = [];
  var sum = 0;
  parse.push(+input);
  debugger;
  for (var i =0; i < input.length; i++) {
    parse.push(+input[i]);
  }

  for (var j =0; j < parse.length; j++) {
     sum += parse[j];
  }

  if(sum == numRez) {
    res.push(input);
  } else {
    count++;
  }

  if (count == numRez) {
    return 0;
  }
  getRezult(--input);

  return res;
}

var firstLine = readline();
print('\n');

print(getRezult(+firstLine.split(' ')[0], +firstLine.split(' ')[1], firstLine.split(' ')[2]))

function getRezult (plate, firstCake, secondCake) {
  var allCake = firstCake + secondCake;
  var procentFirst = firstCake / allCake * 100 ;
  var plateForFirst = Math.round(plate * procentFirst / 100);
  var plateForSecond = plate - plateForFirst;
  var pathOfFirst = Math.floor(firstCake / plateForFirst);
  var pathOfSecond = Math.floor(secondCake / plateForFirst);

  return pathOfFirst < pathOfSecond ? pathOfFirst : pathOfSecond;
}

var firstLine = readline();

var args = firstLine.split(' ');

var count = 0;
var numRez = firstLine.split(' ')[0];
var res = [];

print(getRezult(numRez));
print(0);

function getRezult (num) {
  var input = `${num}`;
  var parse = [];
  var sum = 0;
  parse.push(+input);
  debugger;
  for (var i =0; i < input.length; i++) {
    parse.push(+input[i]);
  }

  for (var j =0; j < parse.length; j++) {
     sum += parse[j];
  }

  if(sum == numRez) {
    res.push(input);
  } else {
    count++;
  }

  if (count == numRez) {
    return 0;
  }
  getRezult(--input);

  return res;
}

var firstLine = readline();

var args = firstLine.split(' ');

var count = 0;
var numRez = firstLine.split(' ')[0];
var res = [];
var rezult = getRezult(numRez)

print(rezult.length || '');
print(rezult);

function getRezult (num) {
  var input = `${num}`;
  var parse = [];
  var sum = 0;
  parse.push(+input);
  debugger;
  for (var i =0; i < input.length; i++) {
    parse.push(+input[i]);
  }

  for (var j =0; j < parse.length; j++) {
     sum += parse[j];
  }

  if(sum == numRez) {
    res.push(input);
  } else {
    count++;
  }

  if (count == numRez) {
    return 0;
  }
  getRezult(--input);

  return res;
}

var firstLine = readline();

var rezult = findMagicNumbers(+firstLine.split(' ')[0]);

print(rezult.length);
print(rezult.join(' '));

function findMagicNumbers(inputValue) {
  var numbers = [];

  for (var i = 1; i < 82; i++) {
    var current = inputValue - i;
    var sum = ('' + current).split('').reduce((sumTemp, num) => sumTemp + num, 0);

    if (sum === current) {
      number.push(sum);
    }
  }

  return numbers;
}

var firstLine = readline();
print('\n');

var args = firstLine.split(' ');

var count = 0;
var numRez = firstLine.split(' ')[0];
var res = [];

print(res.length, getRezult(numRez));

function getRezult (num) {
  var input = `${num}`;
  var parse = [];
  var sum = 0;
  parse.push(+input);
  debugger;
  for (var i =0; i < input.length; i++) {
    parse.push(+input[i]);
  }

  for (var j =0; j < parse.length; j++) {
     sum += parse[j];
  }

  if(sum == numRez) {
    res.push(input);
  } else {
    count++;
  }

  if (count == numRez) {
    return 0;
  }
  getRezult(--input);

  return res;
}

var inside = readline();

print('\n');
var num = +inside.split(' ')[0]

print(getRezult(num))
var count = 0;
function getRezult (num) {
  var input = `${num}`;
  var parse = [];
  var sum = 0;
  var res = [];
  parse.push(+input);

  for (var i =0; i < input.length; i++) {
    parse.push(+input[i]);
  }

  for (var j =0; j < parse.length; j++) {
     sum += parse[j];
  }

  if(sum === num) {
    res.push(input);
  } else {
    count++;

    if (count === num) {
      return 0;
    }
    getRezult(--input);
  }

  return res;
}

var firstLine = readline();

var args = firstLine.split(' ');

var count = 0;
var numRez = firstLine.split(' ')[0];
var res = [];
var rezult = getRezult(numRez)

print(rezult.length);
print(rezult);

function getRezult (num) {
  var input = `${num}`;
  var parse = [];
  var sum = 0;
  parse.push(+input);
  debugger;
  for (var i =0; i < input.length; i++) {
    parse.push(+input[i]);
  }

  for (var j =0; j < parse.length; j++) {
     sum += parse[j];
  }

  if(sum == numRez) {
    res.push(input);
  } else {
    count++;
  }

  if (count == numRez) {
    return 0;
  }
  getRezult(--input);

  return res;
}

var firstLine = readline();
print('\n');

var args = firstLine.split(' ');

var count = 0;
var numRez = firstLine.split(' ')[0];
var res = [];

print(getRezult(numRez));

function getRezult (num) {
  var input = `${num}`;
  var parse = [];
  var sum = 0;
  parse.push(+input);
  debugger;
  for (var i =0; i < input.length; i++) {
    parse.push(+input[i]);
  }

  for (var j =0; j < parse.length; j++) {
     sum += parse[j];
  }

  if(sum == numRez) {
    res.push(input);
  } else {
    count++;
  }

  if (count == numRez) {
    return 0;
  }
  getRezult(--input);

  return res;
}

var firstLine = readline();

var rezult = findMagicNumbers(+firstLine.split(' ')[0]);

print(rezult.length);
rezult.forEach(function(num) {
  print(num);
})

function findMagicNumbers(inputValue) {

  function findSumOfDigits(num) {
    var digits = String(num)
      .split('')
      .map(function(digit) {
        return Number(digit);
      });

    var sumOfDigits = digits.reduce(function(sum, digit) {
      return sum + digit;
    }, 0);

    return sumOfDigits;
  }

  var numbers = [];

  for (var i = 1; i < 82; i++) {
    var current = inputValue - i;

    if (current <= 0) {
      continue;
    }

    var sum = findSumOfDigits(current);

    if (sum + current === inputValue) {
      numbers.push(current);
    }
  }

  return numbers;
}

var firstLine = readline();
print('\n');

var args = firstLine.split(' ');

print(tort(firstLine.split(' ')[0], firstLine.split(' ')[1], firstLine.split(' ')[2]));

function tort(k, x, y) {
  var maxMin = 0;

  for (var i = 1; i < k; i++) {
      var curr = Math.min(Math.floor(x / i), Math.floor(y / (k - i)));
      if (curr > maxMin) {
          maxMin = curr;
      }
  }

  return maxMin;
}

var firstLine = readline();
print('\n');

var args = firstLine.split(' ');

var count = 0;
var numRez = firstLine.split(' ')[0];
var res = [];

print(0 ,getRezult(numRez));

function getRezult (num) {
  var input = `${num}`;
  var parse = [];
  var sum = 0;
  parse.push(+input);
  debugger;
  for (var i =0; i < input.length; i++) {
    parse.push(+input[i]);
  }

  for (var j =0; j < parse.length; j++) {
     sum += parse[j];
  }

  if(sum == numRez) {
    res.push(input);
  } else {
    count++;
  }

  if (count == numRez) {
    return 0;
  }
  getRezult(--input);

  return res;
}

'use strict';
var n = parseInt(readline());
var res = new Array;
var nLength = n.toString().length;
        for (var i = n - 9*nLength; i <(n - 1) && i > 0; i++) {
            var sum = 0, t = i;
                while (t) {
                    sum += t % 10;
                    t = Math.floor(t / 10);
                }
                if (sum + i === n)
                res.push(i);
            }
    print(res.length);
    for (var i = 0; i < res.length; i++)
        print(res[i]);

'use strict';
var n = parseInt(readline());
var res = new Array;
var nLength = n.toString().length;
if (n === 1) {
    res.length = 1;
    print(res.length);
    res[0] = 1;
    print(res[0]);
}
else
    if (n >  1) {
        for (var i = n - 9*nLength; i <n - 1; i++) {
            var sum = 0, t = i;
                while (t) {
                    sum += t % 10;
                    t = Math.floor(t / 10);
                }
                if (sum + i === n)
                res.push(i);
            }
    print(res.length);
    for (var i = 0; i < res.length; i++)
        print(res[i]);
}

function tes(n){
    var i;
    var k = 0;
    var s = [];
    var m = [];
    s = n.toString().split('');
    n < 18 ? i = n : i = 9 * s.length;
    var p;
    while(i >= 0){
        var p = n - i;
        var t = p;
        while(p){
            t += (p % 10);
            p = Math.floor(p / 10);
        }
        if(t === n){
            m.push(n - i);
            k++;
        }
        i--;
    }
    print(k);
    for(var e of m)
    print(e);
}
tes(readline());

var firstEnteredDigit = readline();
//prompt("Enter digit");
var n =  firstEnteredDigit;
var resultArray = [];
var j = 0;

if (n <= 101) {
  j = Math.floor(n / 1.7);
} else if (n <= 1001) {
  j = Math.floor(n / 1.4);
} else if (n <= 10001) {
  j = Math.floor(n / 1.3);
} else if (n <= 100001) {
  j = Math.floor(n / 1.2);
} else if (n <= 1000001) {
  j = Math.floor(n / 1.05);
} else if (n <= 10000001) {
  j = Math.floor(n / 1.025);
} else if (n <= 100000001) {
  j = Math.floor(n / 1.012);
} else if (n <= 1000000001) {
  j = Math.floor(n / 1.006);
}

for (var i = j; i < n; i++) {
  var tempVal = i,
    sumOfDigits = 0;
  while (tempVal) {
    sumOfDigits += tempVal % 10;
    tempVal = Math.floor(tempVal / 10);
  }
  var resultSum = i + sumOfDigits;
  if (resultSum === n) {
    resultArray.push(i);
  }
}

print(resultArray.length);
print(resultArray.toString().replace(',', ' '));
    //console.log(resultArray.length);
    //console.log(resultArray.toString().replace(',', ' '));

var nStr = readline()
var n = +nStr;
var resultArr = [];

for (var i = Math.floor(n / 2); i < n; i++) {
  var sumOfDigits = 0;
  while (tempI) {
	var tempI = i
    sumOfDigits += tempI % 10;
    tempI = Math.floor(tempI / 10);
}
  var resultSum = i + sumOfDigits;
  if (resultSum === n) {
    resultArr.push(i);
  }
}

print(resultArr.length);
print(resultArr.toString().replace(',', ' '));

var nStr = readline();
var n = +nStr;
var resultArr = [];
var j = 0;

if (n <= 101) {
  j = Math.floor(n / 1.5);
} else if (n <= 1001) {
  j = Math.floor(n / 1.4);
} else if (n <= 10001) {
  j = Math.floor(n / 1.3);
} else if (n <= 100001) {
  j = Math.floor(n / 1.2);
} else if (n <= 1000001) {
  j = Math.floor(n / 1.05);
} else if (n <= 10000001) {
  j = Math.floor(n / 1.025);
} else if (n <= 100000001) {
  j = Math.floor(n / 1.012);
} else if (n <= 1000000001) {
  j = Math.floor(n / 1.006);
}

for (var i = j; i < n; i++) {
  var tempI = i,
    sumOfDigits = 0;
  while (tempI) {
    sumOfDigits += tempI % 10;
    tempI = Math.floor(tempI / 10);
  }
  var resultSum = i + sumOfDigits;
  if (resultSum === n) {
    resultArr.push(i);
  }
}

print(resultArr.length);
print(resultArr.toString().replace(',', ' '));

var nStr = readline();
var n = +nStr;
var resultArr = [];
var j = 0;

if(n <= 101) j = Math.floor(n / 1.5);
if(n <= 1001) j = Math.floor(n / 1.4);
if(n <= 10001) j = Math.floor(n / 1.3);
if(n <= 100001) j = Math.floor(n / 1.2);
if(n > 100001) j = Math.floor(n / 1.1);

for (var i = j; i < n; i++) {
  var tempI = i, sumOfDigits = 0;
  while (tempI) {
    sumOfDigits += tempI % 10;
    tempI = Math.floor(tempI / 10);
  }
  var resultSum = i + sumOfDigits;
  if (resultSum === n) {
    resultArr.push(i);
  }
}

print(resultArr.length);
print(resultArr.toString().replace(',', ' '));

var n = readline();
var len = n.toString().length;
function main(){
    var i = n;
    var flag = n - len * 9;
    for(i; i >= flag; i--){
        var subSum = 0;
        var numbers = i.toString().split('');
        numbers.forEach(element => {
            subSum += Number(element);
        });

        if(i+subSum == n){
            print(i+subSum);
        }
    }
}

main();

var n = readline();
var len = n.toString().length;
function main(){
    var i = n;
    var numCounter = 0;
    var flag = n - len * 9;
    var numArr = [];
    for(i; i >= flag; i--){
        var subSum = 0;
        var numbers = i.toString().split('');
        numbers.forEach(element => {
            subSum += Number(element);
        });

        if(i+subSum == n){
            numCounter++
            numArr.unshift(subSum);
        }
    }
    print(numCounter);
    numArr.forEach(element => {
        print(element);
    });
}

main();

var number = parseInt(readline());
var res = new Array;

for (var i = number - 1; i > number - 9*number.toString().length && i > 0; i--) {
    var temp = i
    var sum = 0;
    while (temp) {
        sum += temp % 10;
        temp = Math.floor(temp / 10);
    }

    if (sum + i === number) res.push(i);
}

print(res.length);
print(res);

var number = parseInt(readline());
var res = new Array;

for (var i = number - 1; i > number - 9*number.toString().length && i > 0; i--) {
    var temp = i
    var sum = 0;
    while (temp) {
        sum += temp % 10;
        temp = Math.floor(temp / 10);
    }

    if (sum + i === number) res.push(i);
}

print(res.length);
for (var i = 0; i < res.length; i++ ) print(res[i]);

const
    controlNum = readline()

var matches = 0,
    matchesValues = [],
    num = controlNum;
while (num) {
   var tmpNum = num, sum = 0, tmp;

    while (tmpNum) {
        tmp = tmpNum % 10;
        tmpNum = (tmpNum - tmp) / 10;
        sum += tmp;
    }

    result = num + sum;
    if (result == controlNum) {
        matches++;
        matchesValues.push(num);
        break;
    }
    num--
}

print(matches);
if (matches) {
    for (var j = 0; j < matchesValues.length; j++) {
        print(matchesValues[j]);
    }
}


var n = readline();
var height = 0;
var requiredCubes = 0;
var tmpHeight = 0;

while(n >= 0) {
	tmpHeight++;
	requiredCubes += tmpHeight;
	n -= requiredCubes;

	if(n < 0)
		break;

	height++;
}

print(height);

var n = parseInt(readline());
var it = 0;
var level = 0;
for(;;){
	if ((n - (it + level + 1)) > -1){
		level++;
		it += level;
		n-=it;
	}else{break;}
}
print(level);

///////////////////////////////////////////////////////////////////////////////
function readNumber () { return Number(readline()); }
function readNumbersArray () { return readline().split(' ').map(Number); }
function algebraicSum (startValue, finishValue, size) { return (startValue + finishValue) * size / 2; }
///////////////////////////////////////////////////////////////////////////////

var n = readNumber();
var level = 0;
var levelLength = 1;

while (n > 0) {
	level++;
	levelLength = algebraicSum(1, level, level);
	n -= levelLength;
}

print(level - (n !== 0));

var n =Number(readline());
var level = 0;
var levelUsedCount = 0;
var usedCount = 0;
do{
    level++;
    levelUsedCount+=level;
    usedCount+=levelUsedCount;
} while(usedCount+levelUsedCount+level < n)
print(level);

var n =Number(readline());
var level = 0;
var levelUsedCount = 0;
var usedCount = 0;
do{
    level++;
    levelUsedCount+=level;
    usedCount+=levelUsedCount;
} while(usedCount+levelUsedCount+level+1 <= n)
print(level);

var n = readline();
var height = 0;
var requiredCubes = 0;
var tmpHeight = 1;

while(n >= 0) {
	requiredCubes += tmpHeight;
	n -= requiredCubes;

	if(n < 0)
		break;

	height++;
	tmpHeight++;
}

print(height);

var n = parseInt(readline());
var height = 0;
var requiredCubes = 0;
var tmpHeight = 0;

while(n >= 0) {
	tmpHeight++;
	requiredCubes += tmpHeight;
	n -= requiredCubes;

	if(n < 0)
		break;

	height++;
}

print(height);

var n = parseInt(readline());
var height = 0;
var requiredCubes = 0;
var tmpHeight = 0;

while(n >= requiredCubes) {
	tmpHeight++;
	requiredCubes += tmpHeight;

	if(n >= requiredCubes) {
		height++;
		n -= requiredCubes;
	}
}

print(height);

var n = readline();
height = 0;
sum = 0;
i = 1;
while(n > 0){
    sum += i;
    n -= sum;
    if(n < 0){
        break;
    }
    height++;
    i++;
}
print(height);

var n = parseInt(readline());
var height = 0;
var requiredCubes = 0;
var tmpHeight = 1;

while(n >= 0) {
	requiredCubes += tmpHeight;
	n -= requiredCubes;

	if(n < 0)
		break;

	height++;
	tmpHeight++;
}

print(height);

var number=readline();
var num=0;
var collect=0
var i=0;
// for(i=0;i<number;i++){
    if(number>1){
        while(collect<=number){
            i++
            // console.log("i  "+i);
        num=(i*(i+1))/2;
            // console.log(num);
        collect=collect+num;
        }
        // console.log(collect);
    // }
    // console.log(i-1);
    print(i-1);
    }
    else{
        // console.log(1);
        print(1);
    }

var n = readline();
var res = 0;
var coub = 0;
	for (var i=1; i<+n; i++){

		res += i;
		coub += res;
		if (coub+res+i>=n)
		break;
	}
print(i);

var n = parseInt(readline());
var spent = 0, i = 0, stack = 0;
while(spent <= n){
  i+=1;
  stack += i;
  spent += stack;
}
print(i - 1);

var ans = 0;
var n = parseInt(readline());
var tmp = 0;
var sum = 0;
for (var i=1;sum<=n;i++){
	tmp = tmp + i;
	sum = sum + tmp;
	ans ++;
}
print(ans-1);

function main(){

    var line = readline();
    var n = parseInt(line);

    var row_count = 0;
    var total_cubes = 0;
    var previous_total = 0;

    for(i=1;i<n+1;i++){
	row_count+=i;
	total_cubes += row_count;

	if(n===total_cubes){
	    print(i);
	    return;
	}

	if(n<total_cubes){
	    print(i-1);
	return;
	}
    }

}

main();

function nthSum(index) {
  return (index * (index + 1)) / 2;
}

function main() {
  var cubes = parseInt(readline(), 10);
  var rows = 0;
  var rowIndex = 1;

  while (cubes >= nthSum(rowIndex)) {
    cubes -= nthSum(rowIndex);
    rows++;
    rowIndex++;
  }

  print(rows);
}

main();

var n = parseInt(readline());

var x=0;
var y=0;
var i=0;
while(n>=y){
    i=i+1;
    x+=i;
    y+=x;
}
print(i-1);

//Don't have to see. start------------------------------------------
var read = require('readline').createInterface({
  input: process.stdin, output: process.stdout
});
var obj; var inLine = [];
read.on('line', function(input){inLine.push(input);});
read.on('close', function(){
  obj = init(inLine);
  console.error("\n");
  var start = Date.now();
  Main();
  var end = Date.now() - start;
  myerr("time : " + (end) + "ms");
  myerr("memory : " + Math.round(process.memoryUsage().heapTotal / 1024) + "KB");
});
function makeClone(obj){return JSON.parse(JSON.stringify(obj));}
function nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}
function nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();}
function init(input){
  return {
    list : input, index : 0, max : input.length,
    hasNext : function(){return (this.index < this.max);},
    next : function(){if(this.hasNext()){return this.list[this.index++];}else{throw "ArrayIndexOutOfBoundsException ‚There is no more input";}}
  };
}
function myout(s){console.log(s);}
function myerr(s){console.error("debug:" + require("util").inspect(s,false,null));}
//param "no" is
//unknown or outlier : return i. 1: parseInt.
//2: split space. 4: split space and parseInt.
//6: split 1 character. 7: split 1 character and parseInt.
//8: join space. 9: join nextline. 0: join no character.
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map(Number);case 6:return i.split("");case 7:return i.split("").map(Number);case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}

//Don't have to see. end------------------------------------------
function Main(){
  var N = nextInt();
  var sum = 0;
  for(var i = 1; i < 100000; i++){
    sum += i;
    if(N >= sum){
      N -= sum;
    }else{
      myout(i - 1);
      return;
    }
  }
}

const readline = require('readline');
const rl = readline.createInterface({
  input: process.stdin,
  output: process.stdout,
  terminal: false
});

rl.on('line', (d) => {
  const n = +d;
  let sum = 0;
  let ans = 0;
  let c = 1;

  while (sum < n) {
    let s = 0;
    for (let j = 1; j <= c; j++) {
      s += j;
    }

    sum += s;
    c++;

    if (sum > n) {
      break;
    }
    else {
      ans++;
    }
  }

  console.log(ans);

});

const readline = require('readline');
const rl = readline.createInterface({
  input: process.stdin,
  output: process.stdout,
  terminal: false
});

rl.on('line', (d) => {
  let n = +d;

  let curr = 1;
  let x = 1;

  while (n >= curr) {
    n -= curr;
    x++;
    curr += x;
  }

  console.log(x - 1);

  // let sum = 0;
  // let ans = 0;
  // let c = 1;

  // while (sum < n) {
  //   let s = 0;
  //   for (let j = 1; j <= c; j++) {
  //     s += j;
  //   }

  //   sum += s;
  //   c++;

  //   if (sum > n) {
  //     break;
  //   }
  //   else {
  //     ans++;
  //   }
  // }

  // console.log(ans);

});

const readLine = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout,
});

const input = [];
readLine.on('line', line => input.push(line));

readLine.on('close', () => {
  let [n] = input[0].split(' ').map(x => parseInt(x));
  let prev = 0;

  if (n === 1) { console.log(1); return; }

  for (let i = 1; i < 1000; i += 1) {
    let sum = (i*(i+1))/2;
    prev += sum;

    if (prev > n) {
      console.log(i-1); return;
    }
  }
});

// Sample code to perform I/O:

process.stdin.resume();
process.stdin.setEncoding("utf-8");
var stdin_input = "";

process.stdin.on("data", function (input) {
    stdin_input += input;                               // Reading input from STDIN
});

process.stdin.on("end", function () {
    main(stdin_input);
});

/**
 *
 * @param {*} str
 * @param {*} seperator
 */
function splitter(str, seperator = '') {
    return str.trim().split(seperator);
}

/**
 *
 * @param {*} arr
 */
function strToNumArr(arr = []) {
    return arr.map(num => Number(num));
}

/**
 *
 * @param {*} num1
 * @param {*} num2
 */
function matrixArray(num1, num2) {
    return Array(num1).fill(Array(num2));
}

let log = function () {
    return Function.prototype.bind.call(console.log, console, '');
}();

function removeEmptyItem(arr, index) {
    return arr.slice(0, index).concat(arr.slice(index + 1, arr.length));
}

function range(min, max) {

    let arr = [];
    for (let index = min; index < max; index++) {
        arr.push(index);

    }
    return arr;
}

function main(input) {
    let output = nameLookUp(input);
    process.stdout.write(output);       // Writing output to STDOUT
}

// Warning: Printing unwanted or ill-formatted data to output will cause the test cases to fail

// Write your code here
function nameLookUp(str) {

    let n = +str.trim();
    let count = 0;
    let inc = 0;
    while (count <= n) {
        inc++;
        count += (inc * (inc + 1)) / 2;
    }
    return (inc - 1).toString();
}

const readline = require('readline');
const rl = readline.createInterface({
  input: process.stdin,
  output: process.stdout,
  terminal: false
});

rl.on('line', (d) => {
  const n = +d;
  let sum = 0;
  let ans = 0;

  if (n <= 2) {
    console.log(1);
    return;
  }

  for(let i = 1; i <= n; i++) {
    sum += sum + i;

    if (sum >= n) {
      ans = i;
      break;
    }
  }

  console.log(ans);

});

const readline = require('readline');
const rl = readline.createInterface({
  input: process.stdin,
  output: process.stdout,
  terminal: false
});

rl.on('line', (d) => {
  const n = +d;
  let sum = 0;
  let ans = 0;

  for(let i = 1; i <= n; i++) {
    sum += sum + i;

    if (sum >= n) {
      ans = i;
      break;
    }
  }

  console.log(ans);

});

var n = parseInt(readline());
var it = 0;
var level = 0;
while(n >= it){
	level++;
	it += level;
    n-=it;
	print(it);
}
print(level);

var n = parseInt(readline());
var it = 0;
var level = 0;
while(n >= it){
	level++;
	it += level;
    n-=it;
}
print(level);

var n =Number(readline());
var level = 0;
var levelUsedCount = 0;
var usedCount = 0;
do{
    level++;
    levelUsedCount+=level;
    usedCount+=levelUsedCount;
} while(usedCount+levelUsedCount+level+1 < n)
print(level);

var n = readline();
var res = 0;
var coub = 0;
	for (var i=1; i<+n; i++){

		res += i;
		coub += res;
		if (coub+res>=+n)
		break;
	}
print(i);

var n = parseInt(readline());
var i;
var sum = 1;
for (i=0;n>0;i++){
	n = n - sum;
	sum = sum + 2;
}
print(i);

var n = parseInt(readline());
var i;
var sum = 1;
for (i=1;n>0;i++){
	n = n - sum;
	sum = sum + 2;
}
print(i);

var n = parseInt(readline());
var ans = 0;
var sum = 0;
for (var i=1;i<=n;i++){
	sum = sum + i;
	ans = ans + sum;
}
print(ans);

var n = parseInt(readline());
var i;
var sum = 1;
for (i=0;n-sum>=0;i++){
	n = n - sum;
	sum = sum + i + 1;
}
print(i);

var n = parseInt(readline());
var ans = 0;
var sum = 1;
for (var i=1;i<=n;i++){
	ans = ans + sum;
	sum = sum + 2;
}
print(ans);

var ans = 0;
var n = parseInt(readline());
var tmp = 0;
var sum = 0;
for (var i=1;sum<=n;i++){
	tmp = tmp + i;
	sum = sum + tmp;
	ans ++;
}
print(ans);

"use strict";

var n = +readline();

var result = 0;
for (let i = 1, s = 0; s < n; ++i, s += i) {
  n -= s;
  ++result;
}

write(result);
"use strict";

var n = +readline();

var result = 0;
for (let i = 1, s = 1; s <= n; ++i, s += i) {
  n -= s;
  ++result;
}

write(result);

var n = readline();
var result;
var x=0;
for(var i=1;i<n;i++){
    x+=i;
    if (n-x<0){
        print(i-1);
        break;
    }
    n=n-x;
}


var inp = [];
inp.push(parseInt(readline()));
inp.push(parseInt(readline()));
inp.push(parseInt(readline()));
var M = Math;
var sortF = function(a,b){return a > b;};

var res = M.max(inp[0]*inp[1]*inp[2], inp[2]*(inp[0]+inp[1]), inp[0] + inp[1] + inp[2], inp[0] * (inp[2] + inp[1]));

print(res);

const readLine = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout,
});

const input = [];
readLine.on('line', line => input.push(line));

readLine.on('close', () => {
  const a = parseInt(input[0]);
  const b = parseInt(input[1]);
  const c = parseInt(input[2]);

  let max  = a + b + c;
  if (a * b * c > max) max = a * b * c;
  if ( (a + b) * c > max) max = (a + b) * c;
  if ( a * (b + c) > max) max = a * (b + c);

  console.log(max);
});

(function () {
    var a = parseInt(readline()),
        b = parseInt(readline()),
        c = parseInt(readline());
    if ((a !== 1) && (b !== 1) && (c !== 1)) {
        print(a * b * c);
    } else if ((a === 1) && (c === 1)) {
        print(a + b + c);
    } else if (a === 1) {
        print((a + b) * c);
    } else if (c === 1) {
        print(a * (b + c));
    } else {
        if (a > c) {
            print(a * (b + c));
        } else {
            print((a + b) * c);
        }
    }
})();

let inputString = '';
let currentLine = 0;
process.stdin.on('data', data => {
	inputString += data;
});
process.stdin.on('end', function () {
	inputString = inputString
		.trim()
		.split('\n')
		.map(str => str.trim());
	main();
});

function readLine() {
	return inputString[currentLine++];
}

function main() {
	const a = readLine() >> 0;
	const b = readLine() >> 0;
	const c = readLine() >> 0;

	let values = [];
	values.push(a + b + c);
	values.push(a * (b + c));
	values.push(a * b + c);
	values.push((a + b) * c);
	values.push(a + b * c);
	values.push(a * b * c);

	console.log(Math.max(...values));
}

var a = readline()*1;
var b = readline()*1;
var c = readline()*1;

var e1 = a+b*c,
	e2 = a*(b+c),
	e3 = (a+b)*c,
	e4 = a*b*c,
	e5 = a+b+c,
	e6 = a*b+c;
var arr = [e1,e2,e3,e4,e5,e6];
print(Math.max.apply(null,arr) );

var a = parseInt(readline(), 10),
    b = parseInt(readline(), 10),
    c = parseInt(readline(), 10),
    result = [];

result.push( (a+b)*c );
result.push( (a*b)+c );
result.push( a+(b*c) );
result.push( a*(b+c) );
result.push( a*b*c );
result.push( a+b+c );

print(result.sort((a,b) => a-b).pop());

var x = parseInt(readline());
var y = parseInt(readline());
var z = parseInt(readline());
print(Math.max( x*y*z , (x+y)*z , x*(y+z) , x+y+z))

function expression(a,b,c){
    var totalEx1 = a+(b*c),
    totalEx2 = a*(b+c),
    totalEx3 = a*b*c,
    totalEx4 = (a+b)*c,
    totalEx5 = a+b+c;
    if (totalEx1 >= totalEx2 && totalEx1 >= totalEx3 && totalEx1 >= totalEx4 && totalEx1 >= totalEx5) {
        return totalEx1;
    }else if (totalEx2 >= totalEx1 && totalEx2 >= totalEx3 && totalEx2 >= totalEx4 && totalEx2 >= totalEx5) {
        return totalEx2;
    }else if (totalEx3 >= totalEx1 && totalEx3 >= totalEx2 && totalEx3 >= totalEx4 && totalEx3 >= totalEx5) {
        return totalEx3;
    }else if (totalEx4 >= totalEx1 && totalEx4 >= totalEx2 && totalEx4 >= totalEx3 && totalEx4 >= totalEx5) {
        return totalEx4;
    }else if (totalEx5 >= totalEx1 && totalEx5 >= totalEx2 && totalEx5 >= totalEx3 && totalEx5 >= totalEx4) {
        return totalEx5;
    }

}
a = readline()
b = readline()
c = readline()
print(expression(parseInt(a),parseInt(b),parseInt(c)));

const readline = require('readline').createInterface({
    input: process.stdin,
    output: process.stdout,
});

const input = [];
readline.on('line', line => input.push(line));

readline.on('close', () => {
    const [a, b, c] = input.map(v => parseInt(v));
    let abc = a * b * c, apbpc = a + b + c, apbc = (a + b) * c, abpc = a * (b + c);
    if (abc > apbpc && abc > apbc && abc > abpc) console.log(abc);
    else if (apbpc > abc && apbpc > apbc && apbpc > abpc) console.log(apbpc);
    else if (apbc > abc && apbc > apbpc && apbc > abpc) console.log(apbc);
    else console.log(abpc);
});

var a = parseInt(readline()),
b = parseInt(readline()),
c = parseInt(readline()),
firstExp = a + b * c,
secondExp = a * (b +c),
thirdExp = a * b * c,
fourthExp = (a + b) * c,
fifthExp = a + b + c,
max = 0;
if(max < firstExp){
    max = firstExp;
}

if(max < secondExp){
    max = secondExp;
}

if(max < thirdExp){
    max = thirdExp;
}

if(max < fourthExp){
    max = fourthExp;
}

if(max < fifthExp){
    max = fifthExp;
}

print(max);

var a = parseInt(readline());
var b = parseInt(readline());
var c = parseInt(readline());

print(Math.max(a + b + c, (a + b) * c, a * (b + c), a * b * c));

var v1= parseInt(readline());
var v2 = parseInt(readline());
var v3 =parseInt(readline());

var sumSum = v1+v2+v3;
var sumTimes = v1+(v2*v3);
var sumTimes01 = (v1+v2)*v3;
var timesTimes = v1*v2*v3;
var timesSum = (v1*v2)+v3;
var timesSum01 = v1*(v2+v3);

var list= [sumSum, sumTimes, sumTimes01, timesTimes, timesSum, timesSum01];

print(list.sort(function(a,b){return b-a;})[0]);

let fs = require("fs");

let txt = fs.readFileSync(0, "utf-8").split("\r\n").filter(data => {
    return data.length > 0;
});
for (let i = 0; i < txt.length; i += 3) {
    doit(txt[i] * 1, txt[i + 1] * 1, txt[i + 2] * 1)

}

function doit(n1, n2, n3) {
    let prob = [n1 + n2 + n3,
        n1 * n2 * n3,
        n1 + n2 * n3,
        n1 * n2 + n3,
        (n1 + n2) * n3,
        n1 * (n2 + n3)
    ]
    console.log(Math.max(...prob));
}

'use strict';

(function() {
    let a = parseInt(readline()),
        b = parseInt(readline()),
        c = parseInt(readline());

    function calculateMax(a, b){
      if(a + b > a * b) {
         return a + b;
      }

      return a * b;
    }

    function getMax(a, b) {
      if ( a > b) {
        return a;
      }

      return b;
    }

    let l = calculateMax(a, b);
    let r = calculateMax(b, c);

    let lc = calculateMax(l, c);
    let ra = calculateMax(r, a);

    write(getMax(lc, ra));

})();

(function main() {

    var num1 = parseInt(readline());
    var num2 = parseInt(readline());
    var num3 = parseInt(readline());

    var res1 = num1 + num2 + num3;
    var res2 = num1 * num2 + num3;
    var res3 = num1 + num2 * num3;
    var res4 = num1 * num2 * num3;
    var res5 = (num1 + num2) * num3;
    var res6 = num1 * (num2 + num3);

    print(Math.max(res1, res2, res3, res4, res5, res6));

    return 0;
})();

let inputString = "";
let currentLine = 0;
process.stdin.on("data", (data) => {
  inputString += data;
});
process.stdin.on("end", function () {
  inputString = inputString
    .trim()
    .split("\n")
    .map((str) => str.trim());
  main();
});
function readLine() {
  return inputString[currentLine++];
}
function main() {
  const a = parseInt(readLine());
  const b = parseInt(readLine());
  const c = parseInt(readLine());
  const maxN = Math.max(Math.max(a+b+c, a + (b * c), (a * b) + c), Math.max(a * b * c, a * ( b + c),  (a + b) * c));
  console.log(maxN);
}

Array.prototype.nextPermutation = function() {
   for (var i = this.length - 1; i > 0 && this[i - 1] >= this[i]; --i);
   if (i === 0) return false;
   for (var j = this.length - 1; this[i - 1] >= this[j]; --j);
   this[j] = [this[i - 1], this[i - 1] = this[j]][0];
   for (j = this.length - 1; i < j; ++i, --j) this[j] = [this[i], this[i] = this[j]][0];
   return true;
};

var values = [];
for (var i = 0; i < 3; ++i) {
   values.push(+readline());
}

var operations = ['+', '+', '*', '*'].sort();
var result = 0;

var perform = function(value1, value2, operation) {
   if (operation === '+') {
      return value1 + value2;
   } else {
      return value1 * value2;
   }
};

do {
   result = Math.max(
      result,
      perform(
         perform(values[0], values[1], operations[0]),
         values[2],
         operations[1]
      ),
      perform(
         values[0],
         perform(values[1], values[2], operations[1]),
         operations[0]
      )
   );
} while (operations.nextPermutation());

write(result);

Array.prototype.nextPermutation = function() {
  for (var i = this.length - 1; i > 0 && this[i - 1] >= this[i]; --i);
  if (i === 0) return false;
  for (var j = this.length - 1; this[i - 1] >= this[j]; --j);
  this[j] = [this[i - 1], this[i - 1] = this[j]][0];
  for (j = this.length - 1; i < j; ++i, --j) this[j] = [this[i], this[i] = this[j]][0];
  return true;
};

var values = [];
for (var i = 0; i < 3; ++i) {
  values.push(+readline());
}

var operations = ['+', '+', '*', '*'].sort();
var result = 0;

var perform = function(value1, value2, operation) {
  return operation === '+' ? value1 + value2 : value1 * value2;
};

do {
  result = Math.max(
    result,
    perform(
      perform(values[0], values[1], operations[0]),
      values[2],
      operations[1]
    ),
    perform(
      values[0],
      perform(values[1], values[2], operations[1]),
      operations[0]
    )
  );
} while (operations.nextPermutation());

write(result);

print.call(undefined, (function()    {
    var expression = [ 'a+b+c', 'a*b*c', 'a+b*c', '(a+b)*c', 'a*b+c', 'a*(b+c)' ];

    var a = parseInt(readline()),
        b = parseInt(readline()),
        c = parseInt(readline());

    if(a == b == c == 1)    {
        return 3;
    } else    {
        var result = 0;

        expression.forEach(function(s)    {
            result < eval(s) ? result = eval(s) : false;
        });

        return result;
    }
})());

var a = parseInt(readline());var b = parseInt(readline());var c = parseInt(readline()) ;

var gar = [];
gar.push(a+(b*c));
gar.push(a*(b+c));
gar.push(a*b*c);
gar.push((a+b)*c);
gar.push((a*b)+c);
gar.push(a+b+c);

	print(Math.max(...gar))

var dato1 =parseInt(readline());
var dato2=parseInt(readline());
var dato3=parseInt(readline());

var resultado=[];
var operacion1= dato3 * (dato1 + dato2);
resultado.push(operacion1);
var operacion2= dato1 * (dato2 + dato3);
resultado.push(operacion2);
var operacion3= dato1+dato2+dato3;
resultado.push(operacion3);
var operacion4= dato1*dato2*dato3;
resultado.push(operacion4);

resultado.sort(function(a, b){return b-a});

print(resultado[0]);

//x=readline();
var a = [];
a.push(readline());
 a.push(readline());
 a.push(readline());
/*a = a.sort(function(a,b){
    return a-b;
});*/
var max_stack = [];
//(a+b)*c
max_stack.push(parseInt((parseInt(a[0])+parseInt(a[1]))*parseInt(a[2])));
//a*(b+c)
max_stack.push(parseInt(parseInt(a[0])*((parseInt(a[1])+parseInt(a[2])))));
//a*b*c
max_stack.push(parseInt(parseInt(a[0])*parseInt(a[1])*parseInt(a[2])));

//a*b+c

max_stack.push(parseInt(parseInt(a[0])*parseInt(a[1])+parseInt(a[2])));
//a+b*c
max_stack.push(parseInt(parseInt(a[0])+parseInt(a[1])*parseInt(a[2])));
//a+b+c
max_stack.push(parseInt(parseInt(a[0])+parseInt(a[1])+parseInt(a[2])));

var maximus=-999;
for(i=0;i<max_stack.length;i++)
{
  if(maximus<max_stack[i])
  {
      maximus=max_stack;
  }
}
max_stack=max_stack.sort(function(a,b){
    return b-a;
});
print(max_stack[0]);

//for(i=0;i<a.length;i++)
//print(a[0]);

/*var k = readline();
var c = readline();
var len = 0;
for(i=c.length-1,j=0;i>=0,j<k.length;i--,j++)
{
   if(k[i]==c[j]){
       len++;
   }
}
 if(len==c.length)
 {
     print('YES')
 }
 else
 print('NO')*/

var x = parseInt(readline()),
 y = parseInt(readline()),
 z = parseInt(readline());
 print(Math.max( x*y*z , (x+y)*z , x*(y+z) , x+y+z))

var a = readline();
var b = readline();
var c = readline();
var max = 0;
var max1=0;
var x = 0;
var abc = [a,b,c];
for (i in abc){
	abc[i]=parseInt(abc[i]);
}
if((abc[0] + abc[1])>=(abc[1] * abc[0])) max = abc[0] + abc[1];
else max = abc[0] * abc[1];
if((abc[2] + max)>=(abc[2] * max)) max = abc[2] + max;
else max = abc[2] * max;
if((abc[2] + abc[1])>=(abc[1] * abc[2])) max1 = abc[2] + abc[1];
else max1 = abc[2] * abc[1];
if((abc[0] + max1)>=(abc[0] * max1)) max1 = abc[0] + max1;
else max1 = abc[0] * max1;
if(max1>max) max = max1;
print(max);

var a = parseInt(readline());
var b = parseInt(readline());
var c = parseInt(readline());
print(Math.max(a*b*c,a*b+c,a+b+c,a+b*c,(a+b)*c,a*(b+c)));

	 var a = 0; var b = 0; var c =0;
	 for (var i=0; i<3; i++){
			var x = +readline();
			if(i==0) a = x;
			else if (i==1) b =x;
			else c = x;
	 }
	 var arr = [];
	 arr[0] = a+b*c;
	 arr[1] = a*(b+c);
	 arr[2] = a*b*c;
	 arr[3] = (a+b)*c;
	 arr[4] = a+b+c;
	print(Math.max.apply(this, arr));

var a = +readline(), b = +readline(), c = +readline(), max = 0;

max = ( (a+b+c) > max ) ? (a+b+c) : max;
max = ( (a*b*c) > max ) ? (a*b*c) : max;
max = ( ((a*b)+c) > max ) ? ((a*b)+c) : max;
max = ( (a+(b*c)) > max ) ? (a+(b*c)) : max;
max = ( ((a+b)*c) > max ) ? ((a+b)*c) : max;
max = ( (a*(b+c)) > max ) ? (a*(b+c)) : max;
write(max);

a=+readline();b=+readline();c=+readline();
function x(l,r) { return (function (lb) { return r === 1 ? lb + 1 : lb * r })((l === 1 || b === 1) ? l + b : l * b); }
print(a < c ? x(a, c) : x(c, a))

let readline = require('readline');
let rl = readline.createInterface({
	input: process.stdin,
	output: process.stdout
});

let input = [];

rl.on('line', function(line) {
	input.push(line);
	if (input.length === 3) {
		expression(input);
		rl.close();
	}
});

let expression = (input) => {
	//1+2+3 _ 1*2*3 _ (1+2)*3  _ 1*(2+3)    _ 1*2+3 _ 1+2*3
	input = input.map((el) => {
		return el * 1;
	});

	let val = [
		input[0] + input[1] + input[2],
		input[0] * input[1] * input[2],
		(input[0] + input[1]) * input[2],
		input[0] * (input[1] + input[2]),
		input[0] * input[1] + input[2],
		input[0] + input[1] * input[2]
	];

	var max = val.reduce(function(a, b) {
		return Math.max(a, b);
	});

	console.log(max);
};

a=+readline();b=+readline();c=+readline();

if (a > c) { x = c; c = a; a = x; }
print((function (ab) { return c === 1 ? ab + 1 : ab * c })((a === 1 || b === 1) ? a + b : a * b))

var a = parseInt(readline());
var b = parseInt(readline());
var c = parseInt(readline());
var s = [];
Array.prototype.max = function() {
    return Math.max.apply(null, this);
};
s.push(a*b*c);
s.push(a+b+c);
s.push(a+b*c);
s.push(a*b+c);
s.push((a+b)*c);
s.push(a*(b+c));
print (s.max());

var a = parseInt(readline());
var b = parseInt(readline());
var c = parseInt(readline());
var r = [];
Array.prototype.max = function() {
  return Math.max.apply(null, this);
};
r.push(a*b*c);
r.push(a+b+c);
r.push(a*(b+c));
r.push((a+b)*c);
print(r.max());

function expression(a, b,c) {
    const ab = a+b;
    const bc = b+c;
    const abc = a+b+c;
    return Math.max(ab*c,a*bc,abc,a*b*c);
}

const a = parseInt(readline());
const b = parseInt(readline());
const c = parseInt(readline());

print(expression(a,b,c));

var n1 = parseInt(readline());
var n2 = parseInt(readline());
var n3 = parseInt(readline());

var sort = function(a,b){
    return b - a;
}

var array = [];

array.push(n1+(n2*n3));
array.push(n1+n2+n3);
array.push(n1*(n2+n3))
array.push(n1*n2*n3);
array.push((n1+n2)*n3);

array = array.sort(sort);

print(array[0]);

const readline = require('readline').createInterface({
    input: process.stdin,
    output: process.stdout
})

readline.question("", (a) => {
    readline.question("", (b) => {
        readline.question("", (c) => {
            a=parseInt(a)
            b=parseInt(b)
            c=parseInt(c)
            console.log(Math.max(a + b + c, a + b * c, (a + b) * c, a * b + c, a * (b + c), a * b * c))
            readline.close();
        })
    })
})

//var inputs = readline().split(" ").map(function(x) { return parseInt(x); });
var iPreNum = Number(readline().split(" ").map(function(x) { return parseInt(x); }));
var iMidNum = Number(readline().split(" ").map(function(x) { return parseInt(x); }));
var iFrontNum = Number(readline().split(" ").map(function(x) { return parseInt(x); }));

var iSum = [];
iSum[0] = iPreNum + iMidNum + iFrontNum;
iSum[1] = (iPreNum + iMidNum) * iFrontNum;
iSum[2] = iPreNum * (iMidNum + iFrontNum);
iSum[3] = iPreNum * iMidNum * iFrontNum;

var iFinalAns = iSum[0];

for (var i = 1; i <= 3; i++) {
	if (iFinalAns < iSum[i])
		iFinalAns = iSum[i];
}

print(iFinalAns + "\n");

(function () {

	print(function (a, b, c) {

		return Math.max(
			a * b * c,
			(a + b) * c,
			a * (b + c),
			a + b + c
		);

	}(+readline(), +readline(), +readline()));

}.call(this))

var computeMax = function(arr)
    {
        var decrease = function(a, b)
            {
                return b - a;
            }
        var arrRes = [];
        arrRes.push((arr[0] + arr[1]) * arr[2]);
        arrRes.push(arr[0] * (arr[1] + arr[2]));
        arrRes.push(arr[0] * arr[1] * arr[2]);
        arrRes.push(arr[0] + arr[1] + arr[2]);
        arrRes.push(arr[0] * arr[1] + arr[2]);
        arrRes.push(arr[0] + arr[1] * arr[2]);
        arrRes = arrRes.sort(decrease);
        return arrRes[0];
    }
var arr = [];
for (var i = 1; i <= 3; i++)
    {
        input = +readline();
        arr.push(input);
    }
print(computeMax(arr));

var a = parseInt(readline());
var b = parseInt(readline());
var c = parseInt(readline());

max = a+b+c;

if((a+b*c)>max){
    max = a+b*c;
}
if(((a+b)*c)>max){
    max = (a+b)*c;
}
if((a*b+c)>max){
    max = a*b+c;
}
if((a*(b+c))>max){
    max = a * (b+c);
}
if((a*b*c)>max){
    max = a*b*c;
}
print(max);

a = +readline();
b = +readline();
c = +readline();
ways = [
    a+b+c,
    a+b*c,
    a*b+c,
    a*b*c,
    (a+b)*c,
    a*(b+c)
];
print(Math.max.apply(this, ways));

var a = +readline();
var b = +readline();
var c = +readline();
var list = [
	a + ( b * c ),
	a * ( b + c ),
	a * b * c,
	a + b + c,
	( a + b ) * c,
];

print(Math.max.apply(Math,list));

const start=(main, readlineFun, printFun) => {
  if (readlineFun && printFun) {
    main(readlineFun, printFun);
    return;
  }

  process.stdin.resume();
  process.stdin.setEncoding('utf8');

  let input = '',
    readline,
    print;

  process.stdin.on('data', function(chunk) {
    input += chunk;
  });

  process.stdin.on('end', function() {
    input = input.split('\n');
    print = function(data) {
      process.stdout.write(data + '\n');
    };
    let inputLineIndex = 0;
    readline = function() {
      return inputLineIndex >= input.length ? undefined : input[inputLineIndex++];
    };
    process.exit(main(readline, print) || 0);
  });
}
 function main(readline, print) {
  const a = parseInt(readline());
  const b = parseInt(readline());
  const c = parseInt(readline());

  let max = Math.max(a + b + c, (a + b) * c, a + b * c, a * b + c, a * (b + c), a * b * c);

  print(max);
}
 start(main);

var a = Number(readline());
var b = Number(readline());
var c = Number(readline());

res = Math.max(
        a+b+c,
        (a+b)*c,
        a*(b+c),
        a*b*c
    );

print(res);

// 479A - Expression
// http://codeforces.com/problemset/problem/479/A

function main() {
    let a = [];
    for (let i = 0; i < 3; i++) {
        a.push(parseInt(read()));
    }
    writeline(Math.max(
        a[0] + a[1] + a[2],
        a[0] * (a[1] + a[2]),
        (a[0] + a[1]) * a[2],
        a[0] * a[1] * a[2]));
    return 0;
}

var input = "";
var read;
var writeline = (x) => process.stdout.write(x + "\n");
var write = (x) => process.stdout.write(x);
process.stdin.resume();
process.stdin.setEncoding("utf8");
process.stdin.on("data", (chunk) => input += chunk);
process.stdin.on("end", () => {
    input = input.trim().split(/\s+/);
    read = () => input.shift();
    process.exit(main() || 0);
});

var a=Number.parseInt(readline()),b=Number.parseInt(readline()),c=Number.parseInt(readline())
var ok=a+b+c
ok=Math.max(ok,a*b+c)
ok=Math.max(ok,a+b*c)
ok=Math.max(ok,(a+b)*c)
ok=Math.max(ok,a*(b+c))
ok=Math.max(ok,a*b*c)
print(ok)

var n = Number(readline()), m = Number(readline()), k = Number(readline());
print(Math.max(n*(m+k), n*m*k, (n+m)*k, (n+m+k)));

const readline = require('readline');

let inputs = [];

// Create readline Interface
const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
})

// Read Inputs
rl.on('line', lineInput => {
    inputs.push(lineInput)
})

rl.on('close', () => {

    const nums = inputs.map(num => parseInt(num));

    let maxValue = nums[0] * (nums[1] + nums[2]);

    maxValue = Math.max(maxValue, (nums[0] * nums[1]) * nums[2])
    maxValue = Math.max(maxValue, (nums[0] + nums[1]) + nums[2])
    maxValue = Math.max(maxValue, (nums[0] + nums[1]) * nums[2])

    console.log(maxValue)
})

(function () {
    var a = parseInt(readline()),
        b = parseInt(readline()),
        c = parseInt(readline());
    if ((a !== 1) && (b !== 1) && (c !== 1)) {
        print(a * b * c);
    } else if ((a === 1) && (b === 1) && (c === 1)) {
        print(a + b + c);
    } else if ((a === 1) && (c === 1)) {
        print(a + b + c);
    } else if (a === 1) {
        print((a + b) * c);
    } else if (c === 1) {
        print(a * (b + c));
    } else {
        if (a > c) {
            print(a * (b + c));
        } else {
            print((a + b) * c);
        }
    }
})();

const input = [];

function splitAndParseInt(line) {
  return line.split(" ").map((x) => parseInt(x));
}

const readLine = require("readline").createInterface({
  input: process.stdin,
  output: process.stdout,
});

readLine.on("line", (line) => {
  input.push(line);
});

readLine.on("close", () => {
  const a = parseInt(input[0]);
  const b = parseInt(input[1]);
  const c = parseInt(input[2]);

  console.log(
    Math.max(
      a + b + c,
      a * b * c,
      a * (b + c),
      (a + b) * c,
      a * (c + b),
      (a + b) * c
    )
  );
});

'use strict';

(function() {
    let a = parseInt(readline()),
        b = parseInt(readline()),
        c = parseInt(readline());

    let array = [a,b,c];

    let str = array.join('').replace(new RegExp('1', 'g'), '');

    if(3 - str.length >= 2) {
        write(a+b+c);
        return;
    }

    let indexOfOne = array.indexOf(1);

    if(indexOfOne === -1){
        write(a*b*c);
    } else if(indexOfOne === 0) {
      write((array[0] + array[1])*array[2]);
    } else if (indexOfOne === 2) {
      write((array[2] + array[1])*array[0]);
    } else {
        array.sort((a, b) => a - b);

        write((a[0] + a[1])*a[2]);
    }

    return;

})();

var n = readline();
var res = 0;
for (var i=0; i<n; i++){
	var n = readline();
	if (n==0||n==1)
 	res+=Number(n);
	else if (res==1)
	res+=Number(n);
     else res*=Number(n);
}
print(res);

a=+readline();b=+readline();c=+readline();print((function x (ab) { return c === 1 ? ab + 1 : ab * c })((a === 1 || b === 1) ? a + b : a * b))

var a = readline();
var b = readline();
var c = readline();
var max = 0;
var abc = [a,b,c];
for (i in abc){
abc[i]=parseInt(abc[i]);
abc.sort(mySort);
if (abc[2]!==1){
if(abc[1]+abc[0]>=abc[1]*abc[0]){
	max = abc[2]*(abc[1]+abc[0]);}
else max = abc[2]*(abc[1]*abc[0]);
}
else max = abc[0]+abc[1]+abc[2];
print(max);
function mySort(a, b){return a-b;}
}

var res = 0;
for (var i=0; i<3; i++){
	var n = readline();
	if (n==0||n==1)
 	res+=Number(n);
	else if (res==1)
	res+=Number(n);
     else {res = 1;
		res*=1*Number(n);
		}
}
print(res);

var a = +readline();
var b = +readline();
var c = +readline();
var list = [
	a + ( b * c ),
	a * ( b + c ),
	a * b * c,
	a + b + c,
	( a + b ) * c,
].sort().reverse();
print(list.pop());

var a = readline()*1;
var b = readline()*1;
var c = readline()*1;

var e1 = a+b*c,
	e2 = a+(b*c),
	e3 = (a+b)*c;
	e4 = a*b*c;

if(e1 >= e2 && e1 >= e3 && e1 >= e4)
	print(e1);
else if(e2 >= e1 && e2 >= e3 && e2 >= e4)
	print(e2);
else if(e3 >= e1 && e3 >= e2 && e3 >= e4)
	print(e3);
else
	print(e4);

let fs = require("fs");

let txt = fs.readFileSync(0, "utf-8").split("\r\n").filter(data => {
    return data.length > 0;
});
for (let i = 0; i < txt.length; i++) {
    let info = txt[i].split(" ")
    doit(info[0] * 1, info[1] * 1,info[2]*1);

}

function doit(n1, n2,n3) {
    if(n1>n3){
        console.log(n1*(n2+n3));
    }else{
        console.log((n1+n2)*n3);
    }
}

var n1 = parseInt(readline());
var n2 = parseInt(readline());
var n3 = parseInt(readline());

var sort = function(a,b){
    return b - a;
}

var array = [];

array.push(n1+(n2*n3));
array.push(n1*(n2+n3))
array.push(n1*n2*n3);
array.push((n1+n2)*n3);

array = array.sort(sort);

print(array[0]);

var m = Number(readline()), n = Number(readline()), k = Number(readline());
print(Math.max(n+m*k, n*(m+k), n*m*k, (n+m)*k, (n+m+k)));

print.call(undefined, (function(a)    {
    var expression = [ 'a+b+c', 'a*b*c', 'a+b*c', '(a+b)*c', 'a*b+c', 'a*(b+c)' ];

    var b = parseInt(readline()),
        c = parseInt(readline()),
        array = [ a, b, c ];

    if(a == b == c == 1)    {
        return 3;
    } else    {
        var result = 0;

        expression.forEach(function(s)    {
            result < eval(s) ? result = eval(s) : false;
        });

        return result;
    }
}).apply(undefined, readline().split('').map(Number)));

var res = 0;
var x =0;		          ////580A
for (var i=0; i<3; i++){
	var n = readline();
	n==0||n==1? x+=Number(n):res*=Number(n)
}
 print(res+x);

'use strict';

(function() {
    let a = parseInt(readline()),
        b = parseInt(readline()),
        c = parseInt(readline());

    let array = [a,b,c];

    let str = array.join('').replace(new RegExp('1', 'g'), '');

    if(3 - str.length >= 2) {
        write(a+b+c);
        return;
    }

    let indexOfOne = array.indexOf(1);

    if(indexOfOne === -1){
        write(a*b*c);
    } else if(indexOfOne === 0) {
      write((array[0] + array[1])*array[2]);
    } else if (indexOfOne === 2) {
      write((array[2] + array[1])*array[0]);
    } else {
        array.sort((a, b) => a - b);

        write((array[0] + array[1])*array[2]);
    }

    return;

})();

(function () {
    var a = parseInt(readline()),
        b = parseInt(readline()),
        c = parseInt(readline());
    if ((a !== 1) && (b !== 1) && (c !== 1)) {
        print(a * b * c);
    } else if ((a === 1) && (b === 1) && (c === 1)) {
        print(a + b + c);
    } else if (a === 1) {
        print((a + b) * c);
    } else if (c === 1) {
        print(a * (b * c));
    } else {
        if (a > c) {
            print(a * (b * c));
        } else {
            print((a * b) * c);
        }
    }
})();

var inputs = readline().split(" ").map(function(x) { return parseInt(x); });
var n = inputs[0], m = inputs[1], a = inputs[2];

print(n + " " + m + " " + a);

	 var a = 0; var b = 0; var c =0;
	 for (var i=0; i<3; i++){
			var x = +readline();
			if(i==0) a = x;
			else if (i==2) b =x;
			else c = x;
	 }
	 var arr = [];
	 arr[0] = a+b*c;
	 arr[1] = a*(b+c);
	 arr[2] = a*b*c;
	 arr[3] = (a+b)*c;
	print(Math.max.apply(this, arr));

var a = parseInt(readline());
var b = parseInt(readline());
var c = parseInt(readline());

var max = a;

if(a==0 || b==0 || a==1 || b==1){
    max = max + b;
    if(max==0 || c==0 || max==1 || c==1){
        max = max + c;
    } else {
        max = max * c;
    }
} else{
    max = max * b;
    if(max==0 || c==0 || max==1 || c==1){
        max = max + c
    } else {
        max = max * c;
    }
}

print(max);

'use strict';

(function() {
    let a = parseInt(readline()),
        b = parseInt(readline()),
        c = parseInt(readline());

    if(a === 1 && b === 1 && c === 1) {
        write(3);
        return;
    }

    let array = [a,b,c];

    let indexOfOne = array.indexOf(1);

    if(indexOfOne === -1){
        write(a*b*c);
    } else if(indexOfOne === 0 || indexOfOne === 2) {
        write((a[0] + a[1])*a[2]);
    } else {
        array.sort((a, b) => a - b);

        write((a[0] + a[1])*a[2]);
    }

    return;

})();

var computeMax = function(arr)
    {
        var decrease = function(a, b)
            {
                return b - a;
            }
        var arrRes = [];
        arrRes.push((arr[0] + arr[1]) * arr[2]);
        arrRes.push(arr[0] * (arr[1] + arr[2]));
        arrRes.push(arr[0] * arr[1] * arr[2]);
        arrRes.push(arr[0] + arr[1] + arr[2]);
        arrRes.push(arr[0] * arr[1] + arr[2]);
        arrRes.push(arr[0] + arr[1] * arr[2]);
        arrRes = arrRes.sort(decrease);
        return arr[0];
    }
var arr = [];
for (var i = 1; i <= 3; i++)
    {
        input = +readline();
        arr.push(input);
    }
print(computeMax(arr));

var a = parseInt(readline()),
b = parseInt(readline()),
c = parseInt(readline()),
firstExp = a + b * c,
secondExp = a * (b +c),
thirdExp = a * b * c,
fourthExp = (a + b) * c,
max = 0;
if(max < firstExp){
    max = firstExp;
}

if(max < secondExp){
    max = secondExp;
}

if(max < thirdExp){
    max = thirdExp;
}

if(max < fourthExp){
    max = fourthExp;
}

print(max);

const readline = require('readline').createInterface({
    input: process.stdin,
    output: process.stdout,
});

const input = [];
readline.on('line', line => input.push(line));

readline.on('close', () => {
    const ints = input.map(v => parseInt(v));
    if (ints[0] === 1 && ints[1] === 1 && ints[2] === 1) console.log(ints[0] + ints[1] + ints[2]);
    else if (ints.every(v => v > 1)) console.log(ints[0] * ints[1] * ints[2]);
    else if ((ints[0] + ints[1]) >= ints[2]) console.log((ints[0] + ints[1]) * ints[2]);
    else console.log(ints[0] * (ints[1] + ints[2]));
});

var res = 0;
for (var i=0; i<3; i++){
	var n = readline();
	if (n==0||n==1)
 	res+=Number(n);
	else if (res==1)
	res+=Number(n);
     else {res = 1;
		res*=1*Number(n);
		}
}
print(res);

var res =0;
for (var i=0; i<3; i++){
	var n = readline();
    if (res==0)
	res+=Number(n);
	else if (res==1)
		res+=Number(n);
		else if (n==1) res+=Number(n);
	else res*=Number(n);
}
print(res);

let fs = require("fs");

let txt = fs.readFileSync(0, "utf-8").split("\r\n").filter(data => {
    return data.length > 0;
});
for (let i = 0; i < txt.length; i+=3) {
    doit(txt[i]*1, txt[i+1] * 1,txt[i+2]*1);

}

function doit(n1, n2,n3) {
    if(n1>n3){
        console.log(n1*(n2+n3));
    }else{
        console.log((n1+n2)*n3);
    }
}

//var inputs = readline().split(" ").map(function(x) { return parseInt(x); });
var iPreNum = readline().split(" ").map(function(x) { return parseInt(x); });
var iMidNum = readline().split(" ").map(function(x) { return parseInt(x); });
var iFrontNum = readline().split(" ").map(function(x) { return parseInt(x); });

var iSum = [];
iSum[0] = iPreNum + iMidNum + iFrontNum;
iSum[1] = (iPreNum + iMidNum) * iFrontNum;
iSum[2] = iPreNum * (iMidNum + iFrontNum);
iSum[3] = iPreNum * iMidNum * iFrontNum;

var iFinalAns = iSum[0];

for (var i = 1; i <= 3; i++) {
	if (iFinalAns < iSum[i])
		iFinalAns = iSum[i];
}

print(iFinalAns + "\n");

	 var res = 0;
	 for (var i=0; i<3; i++){
		var c = +readline();
		if (res+c>res*c)
			res+=c;
		else res*=c;
	 }
	 print(res);

var res = 0;
	for (var i=0; i<3; i++){
		var str = Number(readline());
		if (str==1||i==0||str==1)
			res+=str;
		else res*= str;

	}
print(res);

let inputString = "";
let currentLine = 0;
process.stdin.on("data", (data) => {
  inputString += data;
});
process.stdin.on("end", function () {
  inputString = inputString
    .trim()
    .split("\n")
    .map((str) => str.trim());
  main();
});
function readLine() {
  return inputString[currentLine++];
}
function main() {
  const a = parseInt(readLine());
  const b = parseInt(readLine());
  const c = parseInt(readLine());
  const maxN = Math.max(Math.max(a + (b * c), (a * b) + c), Math.max(a * b * c, (a + b) * c));
  console.log(maxN);
}

const readline = require('readline').createInterface({
    input: process.stdin,
    output: process.stdout,
});

const input = [];
readline.on('line', line => input.push(line));

readline.on('close', () => {
    const ints = input.map(v => parseInt(v));
    if (ints[0] === 1 && ints[1] === 1 && ints[2] === 1) console.log(ints[0] + ints[1] + ints[2]);
    else if (ints.every(v => v > 2)) console.log(ints[0] * ints[1] * ints[2]);
    else if ((ints[0] + ints[1]) >= ints[2]) console.log((ints[0] + ints[1]) * ints[2]);
    else console.log(ints[0] * (ints[1] + ints[2]));
});

Array.prototype.nextPermutation = function() {
   for (var i = this.length - 1; i > 0 && this[i - 1] >= this[i]; --i);
   if (i === 0) return false;
   for (var j = this.length - 1; this[i - 1] >= this[j]; --j);
   this[j] = [this[i - 1], this[i - 1] = this[j]][0];
   for (j = this.length - 1; i < j; ++i, --j) this[j] = [this[i], this[i] = this[j]][0];
   return true;
};

var values = [];
for (var i = 0; i < 3; ++i) {
   values.push(+readline());
}

var operations = ['+', '+', '*', '*'].sort();
var result = 0;

var perform = function(value1, value2, operation) {
   if (operations[0] === '+') {
      return value1 + value2;
   } else {
      return value1 * value2;
   }
};

do {
   result = Math.max(
      result,
      perform(
         perform(values[0], values[1], operations[0]),
         values[2],
         operations[1]
      )
   );
} while (operations.nextPermutation());

write(result);

const readline = require('readline');

let inputs = [];

// Create readline Interface
const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
})

// Read Inputs
rl.on('line', lineInput => {
    inputs.push(lineInput)
})

rl.on('close', () => {

    const nums = inputs.map(num => parseInt(num));
    const minimum = Math.min(...nums);
    const maximum = Math.max(...nums);
    let maxValue = 0;

    // If first number == 0
    if (minimum == 0) {
        if ((nums[1] * nums[2]) == 1) {
            maxValue = nums[1] + nums[2]
            return console.log(maxValue)
        } else {
            maxValue = nums[1] * nums[2]
            return console.log(maxValue)
        }
    } else if (minimum == 1) {
        const others = nums.filter(num => num != maximum).reduce((prev, curr) => prev += curr, 0)
        maxValue = maximum * others;
        return console.log(maxValue)
    } else {
        maxValue = nums.reduce((prev, curr) => prev *= curr);
        return console.log(maxValue)
    }

})

let fs = require("fs");

let txt = fs.readFileSync(0, "utf-8").split("\r\n").filter(data => {
    return data.length > 0;
});
for (let i = 0; i < txt.length; i+=3) {
    doit([txt[i]*1, txt[i+1] * 1,txt[i+2]*1].sort((a,b)=>{return a-b}));

}

function doit(tab) {
  for (let i = 0; i < 2; i++) {
      if(tab[i]==1){
          tab[i+1]+=tab[i]
      }

  }
  if(tab[tab.length-1]==1){
      tab[tab.length-2]+=tab[tab.length-1];
  }
  console.log(tab[0]*tab[1]*tab[2]);

}

const readline = require('readline');

let inputs = [];

// Create readline Interface
const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
})

// Read Inputs
rl.on('line', lineInput => {
    inputs.push(lineInput)
})

rl.on('close', () => {

    const nums = inputs.map(num => parseInt(num));
    const minimum = Math.min(...nums);
    const maximum = Math.max(...nums);
    const othersValue = nums.filter(num => num != maximum).reduce((prev, curr) => prev += curr, 0)
    let maxValue = 0;

    // If first number == 0
    if (minimum == 0) {
        if (nums.includes(1)) {
            maxValue = nums.reduce((prev, curr) => prev += curr, 0)
        }
        else
            maxValue = nums.filter(num => num != 0).reduce((prev, curr) => prev *= curr)
        return console.log(maxValue)
    } else if (minimum == 1) {
        const onesSum = nums.filter(num => num == 1).reduce((prev, curr) => prev += curr, 0);
        let othersMulti = nums.filter(num => num != 1);

        if (othersMulti.length) {
            othersMulti = othersMulti.reduce((prev, curr) => prev *= curr);
            maxValue = onesSum + othersMulti;
        }
        else {
            maxValue = onesSum;
        }

        return console.log(maxValue)
    } else {
        maxValue = nums.reduce((prev, curr) => prev *= curr);
        return console.log(maxValue)
    }

})

var dato1 =parseInt(readline());
var dato2=parseInt(readline());
var dato3=parseInt(readline());

var operacion1= dato3 * (dato1 + dato2);

var operacion2= dato1 * (dato2 + dato3);

var operacion3=(dato1+dato3)*dato2;

var resultado=0;

if(dato1>1 && dato2>1 && dato3>1){
    print(dato1*dato2*dato3);
}else if(dato1==1 && dato2==1 && dato3==1){
    print(dato1+dato2+dato3)
}
    else if(operacion1>operacion2 && operacion1>operacion3){
    print(operacion1);
    }
        else if(operacion2>operacion1 && operacion2>operacion3){
            print(operacion2);
        } else{print(operacion3);}

var n = readline();
var res = 0;
for (var i=0; i<n; i++){
	var n = readline();
	if (n==0||n==1)
 	res+=Number(n);
	else if (res==1)
	res+=Number(n);
     else res*=Number(n);
}
print(res);

var res =0;
for (var i=0; i<3; i++){
	var n = readline();
    if (n==1)
	res+=Number(n);
	else if (res==1)
		res+=Number(n);
	else  res*=Number(n);
}
print(res);

var res = 0;		          ////580A
for (var i=0; i<3; i++){
	var n = readline();
	n===0||n==1? res+=Number(n):res*=Number(n)
}
 print(res);

var a = Number(readline());
var b = Number(readline());
var c = Number(readline());
var res;
if (a != 1 && b != 1 && c!=1) {
    res = a*b*c;
}
else {
    if (a+b+c - Math.max(a, b, c) == 2) {
        res = a+b+c;
    }
    else if (a == 1) {
        res = (a+b)*c
    }
    else if (b == 1) {
        res = (Math.min(a, c) + 1) * Math.max(a, c);
    }
    else if (c == 1) {
        res  = a*(b+c);
    }
}

print(res);

//var inputs = readline().split(" ").map(function(x) { return parseInt(x); });
var iPreNum = readline().split(" ").map(function(x) { return parseInt(x); });
var iMidNum = readline().split(" ").map(function(x) { return parseInt(x); });
var iFrontNum = readline().split(" ").map(function(x) { return parseInt(x); });

var iSum = new Array();
iSum[0] = iPreNum + iMidNum + iFrontNum;
iSum[1] = (iPreNum + iMidNum) * iFrontNum;
iSum[2] = iPreNum * (iMidNum + iFrontNum);
iSum[3] = iPreNum * iMidNum * iFrontNum;

var iFinalAns = iSum[0];

for (var i = 1; i <= 3; i++) {
	if (iFinalAns < iSum[i])
		iFinalAns = iSum[i];
}

print(iFinalAns + "\n");

const readline = require('readline');

let inputs = [];

// Create readline Interface
const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
})

// Read Inputs
rl.on('line', lineInput => {
    inputs.push(lineInput)
})

rl.on('close', () => {

    const nums = inputs.map(num => parseInt(num));
    const minimum = Math.min(...nums);
    const maximum = Math.max(...nums);
    const othersValue = nums.filter(num => num != maximum).reduce((prev, curr) => prev += curr, 0)
    let maxValue = 0;

    // If first number == 0
    if (minimum == 0) {
        if (nums.includes(1)) {
            maxValue = nums.reduce((prev, curr) => prev += curr, 0)
        }
        else
            maxValue = nums.filter(num => num != 0).reduce((prev, curr) => prev *= curr)
        return console.log(maxValue)
    } else if (minimum == 1) {
        const onesSum = nums.filter(num => num == 1).reduce((prev, curr) => prev += curr, 0);
        let othersMulti = nums.filter(num => num != 1);

        if (othersMulti.length) {
            othersMulti = othersMulti.reduce((prev, curr) => prev *= curr);
            maxValue = onesSum + othersMulti;
        }
        else
            maxValue = onesSum;

        return console.log(maxValue)
    } else {
        maxValue = nums.reduce((prev, curr) => prev *= curr);
        return console.log(maxValue)
    }

})

'use strict';

(function() {
    let a = parseInt(readline()),
        b = parseInt(readline()),
        c = parseInt(readline());

    let array = [a,b,c];

    let str = array.join();
    str = str.split('1');

    if(3 - str.length >= 2) {
        write(a+b+c);
        return;
    }

    let indexOfOne = array.indexOf(1);

    if(indexOfOne === -1){
        write(a*b*c);
    } else if(indexOfOne === 0) {
      write((array[0] + array[1])*array[2]);
    } else if (indexOfOne === 2) {
      write((array[2] + array[1])*array[0]);
    } else {
        array.sort((a, b) => a - b);

        write((a[0] + a[1])*a[2]);
    }

    return;

})();

var a=readline(),b=readline(),c=readline()
if (a==b && b==c && c==1){
    print("3")
}else if (a==b && a==1){
    print((a+b)*c)
}else if (a==c && a==1){
    print((a+c)*b)
}else if (b==c && b==1){
    print((b+c)*a)
}
else if(a==1){
    print((a+Math.min(b,c))*Math.max(b,c))
}else if(b==1){
    print((b+Math.min(a,c))*Math.max(a,c))

}else if (c==1){
    print((c+Math.min(a,b))*Math.max(a,b))
}else{
    print(a*b*c)
}

var inp = [];
inp.push(parseInt(readline()));
inp.push(parseInt(readline()));
inp.push(parseInt(readline()));
var M = Math;
var sortF = function(a,b){return a > b;};

inp.sort(sortF);

var res = M.max(inp[0]*inp[1]*inp[2], inp[2]*(inp[0]+inp[1]), inp[0] + inp[1] + inp[2], inp[0] * (inp[2] + inp[1]));

print(res);

var res = 1;
var x =0;		          ////580A
for (var i=0; i<3; i++){
	var n = readline();
	n==0||n==1? x+=Number(n):res*=Number(n)
}
 print(res+x);

var a = parseInt(readline()),
b = parseInt(readline()),
c = parseInt(readline()),
firstExp = a + b * c,
secondExp = a * (b +c),
thirdExp = a * b * c,
fourthExp = (a + b) * c,
max = 0;
if(max < firstExp){
    max = firstExp;
}

if(max < secondExp){
    max = secondExp;
}

if(max < thirdExp){
    max = thirdExp;
}

if(max < fourthExp){
    max = fourthExp;
}

print(max);

	 var a = 0; var b = 0; var c =0;
	 for (var i=0; i<3; i++){
			if(i==0) a = +readline();
			else if (i==2) b = +readline();
			else c = +readline();
	 }
	 var arr = [];
	 arr[0] = a+b*c;
	 arr[1] = a*(b+c);
	 arr[2] = a*b*c;
	 arr[3] = (a+b)*c;
	print(Math.max.apply(this, arr));

var str = "";
for (var i=0; i<3; i++){
		str += readline();
}
str.split(" ");
var res = +str[0];

	if(+str[1]+res<+str[1]+Number(str[2])){
		res+= +str[1];
		res*= +str[2];
	}
	else {
	   res*=+str[1]+Number(str[2]);
	}
print(res);

var a = parseInt(readline());
var b = parseInt(readline());
var c = parseInt(readline());

var max = a;

if(a==0 || b==0 || a==1 || b==1){
    max = max + b;
    if(max==0 || c==0 || max==1 || c==1){
        max = max + c;
    } else {
        max = max * c;
    }
} else{
    max = max * b;
    if(max==0 || c==0 || max==1 || c==1){
        max = max + c
    } else {
        max = max * c;
    }
}

print(max);

//x=readline();
var a = [];
a.push(readline());
 a.push(readline());
 a.push(readline());
a = a.sort(function(a,b){
    return a-b;
});
var max_stack = [];
//(a+b)*c
max_stack.push(parseInt((parseInt(a[0])+parseInt(a[1]))*parseInt(a[2])));
//a*(b+c)
max_stack.push(parseInt(parseInt(a[0])*(parseInt(a[1])+parseInt(a[2]))));
//a*b*c
max_stack.push(parseInt(parseInt(a[0])*parseInt(a[1])*parseInt(a[2])));

//a*b+c

max_stack.push(parseInt(parseInt(a[0])*parseInt(a[1])+parseInt(a[2])));
//a+b*c
max_stack.push(parseInt(parseInt(a[0])+parseInt(a[1])*parseInt(a[2])));
//a+b+c
max_stack.push(parseInt(parseInt(a[0])+parseInt(a[1])+parseInt(a[2])));

var maximus=-999;
for(i=0;i<max_stack.length;i++)
{
  if(maximus<max_stack[i])
  {
      maximus=max_stack;
  }
}
max_stack=max_stack.sort(function(a,b){
    return b-a;
});
print((max_stack[0]));

//for(i=0;i<a.length;i++)
//print(a[0]);

/*var k = readline();
var c = readline();
var len = 0;
for(i=c.length-1,j=0;i>=0,j<k.length;i--,j++)
{
   if(k[i]==c[j]){
       len++;
   }
}
 if(len==c.length)
 {
     print('YES')
 }
 else
 print('NO')*/

var a = readline();
var b = readline();
var c = readline();
var max = 0;
var abc = [a,b,c];
for (i in abc){
abc[i]=parseInt(abc[i]);}
abc.sort(mySort);
if (abc[2]!==1){
if(abc[1]+abc[0]>=abc[1]*abc[0]){
	max = abc[2]*(abc[1]+abc[0]);}
else max = abc[2]*(abc[1]*abc[0]);
}
else max = abc[0]+abc[1]+abc[2];
print(max);
function mySort(a, b){return a-b;}

var res = readline();
for (var i=0; i<3; i++){
	var n = readline();
	if (n==0||n==1)
 	res+=Number(n);
	else if (res==1)
	res+=Number(n);
     else res*=Number(n);
}
print(res);

var a =parseInt(readline()) ; var b = parseInt(readline()) ; var c = parseInt(readline()) ;
var max = [a,b,c].filter(x => x===1).length
var umax = Math.max(a,b,c);

if(max == 2){
	if((a == b)||(b==c)){print(umax*2)}else{print(a+b+c)}
}

if(max == 1){

	if(a == 1){print((1+b)*c);}
    if(c == 1){print((1+b)*a)}
    if(b == 1){
    	if(a>c){print((a+1)*c)}else{print((c+1)*b)}}

}

if(max == 3){print(3)}
if(max == 0){print(a*b*c)}

var a = readline();
var b = readline();
var c = readline();
var max = 0;
var abc = [a,b,c];
for (i in abc){
abc[i]=parseInt(abc[i]);
}
abc.sort(mySort);
if(abc[1]+abc[0]>abc[1]*abc[0])
max = abc[2]*(abc[1]+abc[0]);
else max = abc[2]*(abc[1]*abc[0]);
print(max);
function mySort(a, b){return a-b;}

var a = readline();
var b = readline();
var c = readline();
var max = 0;
var abc = [a,b,c];
abc.sort(mySort);
if (abc[2]!==1){
if(abc[1]+abc[0]>abc[1]*abc[0]){
	max = abc[2]*(abc[1]+abc[0]);}
else max = abc[2]*(abc[1]*abc[0]);
}
else max = abc[0]+abc[1]+abc[2];
print(max);
function mySort(a, b){return a-b;}

var res = 0;

  var one = Number(readline());
  res+=one; //5

  var two = Number(readline());
  var three = Number(readline());

  if (res==1)
	 res+= two;
	 else if(str==1) {
	 one>three? res*=three+two: res*=one+two;
	}
	res*=two;
	res *= three;
    print(res);

'use strict';

(function() {
    let a = parseInt(readline()),
        b = parseInt(readline()),
        c = parseInt(readline());

    if(a === 1 && b === 1 && c === 1) {
        write(3);
        return;
    }

    let array = [a,b,c];

    let indexOfOne = array.indexOf(1);

    if(indexOfOne === -1){
        write(a*b*c);
    } else if(indexOfOne === 0) {
      write((array[0] + array[1])*array[2]);
    } else if (indexOfOne === 2) {
      write((array[2] + array[1])*array[0]);
    } else {
        array.sort((a, b) => a - b);

        write((a[0] + a[1])*a[2]);
    }

    return;

})();

var a = Number(readline());
var b = Number(readline());
var c = Number(readline());
var res;
if (a != 1 && b != 1 && c!=1) {
    res = a*b*c;
}
else {
    if (a+b+c - Math.max(a, b, c) == 2) {
        res = a+b+c;
    }
    else if (a == 1) {
        res = (a+b)*c
    }
    else if (b == 1) {
        res = (Math.min(a, c) + 1) * Math.max(a, c);
    }
    else if (c == 1) {
        res  = a*(b+c);
    }
}

print(res);

var inp = [];
inp.push(parseInt(readline()));
inp.push(parseInt(readline()));
inp.push(parseInt(readline()));
var M = Math;
var sortF = function(a,b){return a > b;};

inp.sort(sortF);

var res = M.max(inp[0]*inp[1]*inp[2], inp[2]*(inp[0]+inp[1]), inp[0] + inp[1] + inp[2], inp[0] * (inp[2] + inp[1]));

print(res);

var res =0;
for (var i=0; i<3; i++){
	var n = readline();
    if (res==0);
	res+=Number(n);
	if (res==1)
		res+=Number(n);
	else res*=Number(n);
}
print(res);

var a = +readline();
var b = +readline();
var c = +readline();

var max = list = [
	a + ( b * c ),
	a * ( b + c ),
	a * b * c,
	a + b + c,
	( a + b ) * c,
].sort().reverse().pop();

print(max);

let inputString = "";
let currentLine = 0;
process.stdin.on("data", (data) => {
  inputString += data;
});
process.stdin.on("end", function () {
  inputString = inputString
    .trim()
    .split("\n")
    .map((str) => str.trim());
  main();
});
function readLine() {
  return inputString[currentLine++];
}
function main() {
  const a = parseInt(readLine());
  const b = parseInt(readLine());
  const c = parseInt(readLine());
  const maxN = Math.max(Math.max(a + b * c, a * b + c), Math.max(a * b * c, a + b * c));
  console.log(maxN);
}

var str = readline().split(" ");
var res = +str[0];

	if(+str[1]+res<+str[1]+Number(str[2])){
		res+= +str[1];
		res*= +str[2];
	}
	else {
	   res*=+str[1]+Number(str[2]);
	}

print(res);

var inp = [];
inp.push(parseInt(readline()));
inp.push(parseInt(readline()));
inp.push(parseInt(readline()));
var M = Math;
var sortF = function(a,b){return a > b;};

inp.sort(sortF);

var res = M.max(inp[0]*inp[1]*inp[2], inp[2]*(inp[0]+inp[1]), inp[0] + inp[1] + inp[2], inp[0] * (inp[2] + inp[3]));

print(res);

var a=Number.parseInt(readline()),b=Number.parseInt(readline()),c=Number.parseInt(readline())
if (a===b && b===c && c===1){
    print("3")
}else if (a===b && a===1){
    print((a+b)*c)
}else if (a===c && a===1){
    print((a+c)*b)
}else if (b===c && b===1){
    print((b+c)*a)
}
else if(a===1){
    print((a+Math.min(b,c))*Math.max(b,c))
}else if(b===1){
    print((b+Math.min(a,c))*Math.max(a,c))

}else if (c===1){
    print((c+Math.min(a,b))*Math.max(a,b))
}else{
    print(a*b*c)
}

var inputs = readline().split(" ").map(function(x) { return parseInt(x); });
var n = inputs[0], m = inputs[1], a = inputs[2];

print(n + " " + m + " " + a);

	 var a = 0; var b = 0; var c =0;
	 for (var i=0; i<3; i++){
			if(i==0) a = +readline();
			else if (i==2) b = +readline();
			else c = +readline();
	 }
	 var arr = [];
	 arr[0] = a+b*c;
	 arr[1] = a*(b+c);
	 arr[2] = a*b*c;
	 arr[3] = (a+b)*c;
	print(Math.max.apply(this, arr));

var a = readline();
var b = readline();
var c = readline();
var max = 0;
var abc = [a,b,c];
for (i in abc){
abc[i]=parseInt(abc[i]);}
abc.sort(mySort);
if (abc[2]!==1){
if(abc[1]+abc[0]>=abc[1]*abc[0]){
	max = abc[2]*(abc[1]+abc[0]);}
else max = abc[2]*(abc[1]*abc[0]);
}
else max = abc[0]+abc[1]+abc[2];
print(max);
function mySort(a, b){return a-b;}

var a = readline();
var b = readline();
var c = readline();
var max = 0;
var abc = [a,b,c];
for (i in abc){
abc[i]=parseInt(abc[i]);
abc.sort(mySort);}
if (abc[2]!==1){
if(abc[1]+abc[0]>=abc[1]*abc[0]){
	max = abc[2]*(abc[1]+abc[0]);}
else max = abc[2]*(abc[1]*abc[0]);
}
else max = abc[0]+abc[1]+abc[2];
print(max);
function mySort(a, b){return a-b;}

let fs = require("fs");

let txt = fs.readFileSync(0, "utf-8").split("\r\n").filter(data => {
    return data.length > 0;
});
for (let i = 0; i < txt.length; i+=3) {
    doit(txt[i]*1, txt[i+1] * 1,txt[i+2]*1);

}

function doit(n1, n2,n3) {
    if(n1>n3){
        console.log(n1*(n2+n3));
    }else{
        console.log((n1+n2)*n3);
    }
}

//var inputs = readline().split(" ").map(function(x) { return parseInt(x); });
var iPreNum = Number(readline().split(" ").map(function(x) { return parseInt(x); }));
var iMidNum = Number(readline().split(" ").map(function(x) { return parseInt(x); }));
var iFrontNum = Number(readline().split(" ").map(function(x) { return parseInt(x); }));
print(typeof iPreNum);
var iSum = [];
iSum[0] = iPreNum + iMidNum + iFrontNum;
iSum[1] = (iPreNum + iMidNum) * iFrontNum;
iSum[2] = iPreNum * (iMidNum + iFrontNum);
iSum[3] = iPreNum * iMidNum * iFrontNum;

var iFinalAns = iSum[0];

for (var i = 1; i <= 3; i++) {
	if (iFinalAns < iSum[i])
		iFinalAns = iSum[i];
}

print(iFinalAns + "\n");

var a = readline() ; var b = readline() ; var c = readline() ;
var max = [a,b,c].filter(x => x===1).length
var umax = Math.max(a,b,c);

if(max == 2){
	if((a == b)||(b==c)){print(umax*2)}else{print(a+b+c)}
}

if(max == 1){

	if(a == 1){print((1+b)*c);}
    if(c == 1){print((1+b)*a)}
    if(b == 1){
    	if(a>c){print((a+1)*c)}else{print((c+1)*b)}}

}

if(max == 3){print(3)}
if(max == 0){print(a*b*c)}

let inputString = "";
let currentLine = 0;
process.stdin.on("data", (data) => {
  inputString += data;
});
process.stdin.on("end", function () {
  inputString = inputString
    .trim()
    .split("\n")
    .map((str) => str.trim());
  main();
});
function readLine() {
  return inputString[currentLine++];
}
function main() {
  const a = parseInt(readLine());
  const b = parseInt(readLine());
  const c = parseInt(readLine());
  const maxN = Math.max(Math.max(a+b+c, a + (b * c), (a * b) + c), Math.max(a * b * c, (a + b) * c));
  console.log(maxN);
}

var computeMax = function(arr)
    {
        var increase = function(a, b)
            {
                return a - b;
            }
        arr = arr.sort(increase);
        return (arr[0] + arr[1]) * arr[2];
    }
var arr = [];
for (var i = 1; i <= 3; i++)
    {
        var input = +readline();
        arr.push(input);
    }
print(computeMax(arr));

var res = 0;
var x =0;		          ////580A
for (var i=0; i<3; i++){
	var n = readline();
	n==0||n==1? x+=Number(n):res*=Number(n)
}
 print(res+x);

var a = readline();
var b = readline();
var c = readline();
var max = 0;
var abc = [a,b,c];
for (i in abc){
abc[i]=parseInt(abc[i]);
abc.sort(mySort);
if (abc[2]!==1){
if(abc[1]+abc[0]>=abc[1]*abc[0]){
	max = abc[2]*(abc[1]+abc[0]);}
else max = abc[2]*(abc[1]*abc[0]);
}
else max = abc[0]+abc[1]+abc[2];}
print(max);
function mySort(a, b){return a-b;}

var inp = [];
inp.push(parseInt(readline()));
inp.push(parseInt(readline()));
inp.push(parseInt(readline()));
var M = Math;
var sortF = function(a,b){return a > b;};

inp.sort(sortF);

var res = M.max(inp[0]*inp[1]*inp[2], inp[2]*(inp[0]+inp[1]));

print(res);