Self‐consistent calculation of the Fermi level and the electron density in a thin metal film