package sum;

/**
 * @author Nikita Doschennikov (me@fymio.us)
 */
public class SumDoubleHex {

    public static void main(String[] args) {
        double res = 0;
        for (String arg : args) {
            StringBuilder builder = new StringBuilder();
            boolean containsDot = false;
            for (char c : arg.toCharArray()) {
                if (!Character.isWhitespace(c)) {
                    builder.append(c);
                    if (c == '.') {
                        containsDot = true;
                    }
                } else {
                    res += compute(builder.toString(), containsDot);
                    containsDot = false;
                    builder = new StringBuilder();
                }
            }
            res += compute(builder.toString(), containsDot);
        }
        System.out.println(res);
    }

    static double compute(String num, boolean containsDot) {
        double res = 0;
        if (num.isEmpty()) {
            res += 0;
        } else if (
            num.charAt(0) == '0' &&
            (num.charAt(1) == 'x' || num.charAt(1) == 'X')
        ) {
            res += (containsDot) ? Double.parseDouble(num) : Long.decode(num);
        } else {
            res += Double.parseDouble(num);
        }

        return res;
    }
}
