The Euler number from the distance function