Multiplane gravitational lensing. III. Upper bound on number of images