// SumLongOctal.java

import java.math.BigInteger;

public class SumLongOctal {

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

            sum += parseNumber(number);
        }

        System.out.println(sum);
    }

    static long 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
                ).longValue();
            } else {
                return Long.parseLong(numberString);
            }
        } else {
            return 0;
        }
    }
}
