Calculate cost for of