On the finiteness of the discrete spectrum of Hamiltonians for quantum systems of three one- or two-dimensional particles