Four-lepton production in proton-proton collisions, , where or , is studied at a center-of-mass energy of 13 with the CMS detector at the LHC. The data sample corresponds to an integrated luminosity of 35.9 . The ZZ production cross section, , measured using events with two opposite-sign, same-flavor lepton pairs produced in the mass region , is consistent with standard model predictions. Differential cross sections are measured and are well described by the theoretical predictions. The Z boson branching fraction to four leptons is measured to be for events with a four-lepton invariant mass in the range and a dilepton mass for all opposite-sign, same-flavor lepton pairs. The results agree with standard model predictions. The invariant mass distribution of the four-lepton system is used to set limits on anomalous ZZZ and ZZ couplings at 95% confidence level: , , , .