// SumBigIntegerOctal.java

import java.math.BigInteger;

public class SumBigIntegerOctal {

    public static void main(String[] args) {
        BigInteger sum = new BigInteger("0");
        for (String argument : args) {
            StringBuilder number = new StringBuilder();
            for (char c : argument.toCharArray()) {
                if (!Character.isWhitespace(c)) {
                    number.append(c);
                } else {
                    sum = sum.add(parseNumber(number));
                    number = new StringBuilder();
                }
            }

            sum = sum.add(parseNumber(number));
        }

        System.out.println(sum);
    }

    static BigInteger parseNumber(StringBuilder number) {
        if (!number.isEmpty()) {
            String numberString = number.toString();
            int numberStringLength = numberString.length();
            if (numberString.endsWith("o") || numberString.endsWith("O")) {
                return new BigInteger(
                    number.substring(0, numberStringLength - 1),
                    8
                );
            } else {
                return new BigInteger(numberString);
            }
        } else {
            return BigInteger.ZERO;
        }
    }
}
