first_mode function

Calculate the first mode