On the optimal choice of the number of empirical Fourier coefficients for comparison of regression curves