Total Cost Formula