stack with a function min which returns the minimum element