Nonlinear generalization of the Maslov index