contract SafeMath {
    uint256 constant private MAX_UINT256 =
    0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF;

    /**
     * Add two uint256 values, revert in case of overflow.
     *
     * @param a first value to add
     * @param b second value to add
     * @return a + b
     */
    function safeAdd(uint256 a, uint256 b) internal returns (uint256) {
        require (a <= MAX_UINT256 - b);
        uint256 c = a + b;
        assert(c >= a);
        return c;
    }

    /**
     * Subtract one uint256 value from another, throw in case of underflow.
     *
     * @param a value to subtract from
     * @param b value to subtract
     * @return a - b
     */
    function safeSub(uint256 a, uint256 b) internal returns (uint256) {
        assert(a >= b);
        return a - b;
    }

    /**
     * Multiply two uint256 values, throw in case of overflow.
     *
     * @param a first value to multiply
     * @param b second value to multiply
     * @return a * b
     */
    function safeMul(uint256 a, uint256 b) internal returns (uint256) {
        if (a == 0 || b == 0) return 0;
        require (a <= MAX_UINT256 / b);
        return a * b;
    }
}
/**
 * Provides methods to safely add, subtract and multiply uint256 numbers.
 */
function safeSub(uint256 a, uint256 b) internal returns (uint256) {
    assert(a >= b);
    return a - b;
}

/**
 * Subtract one uint256 value from another, throw in case of underflow.
 *
 * @param a value to subtract from
 * @param b value to subtract
 * @return a - b
 */