def EvalOctal(s):
    s = s.strip()

    if (len(s) == 0):
        return -1

    v = 0
    for char in s:
        if ('0' <= char) and (char <= '7'):
            v = 8 * v + int(char)
        else:
            return -1

    return v
