extended real valued function bounded below and attains its minimal value

Let f(x) be a real-valued function (an extended real valued function) on a metric space (M; d). Then

and

A function is called lower (upper) semicontinuous at a point y if

and

and

Let a metric space M be complete, and let K be a compact subset in M. Prove that a lower semicontinuous function on K is bounded from below and attains its minimal value and an upper semicontinuous function on K is bounded from above and attains its maximal value.

Any idea of how to approach this??