Discovery of VHE gamma-ray emission from the BL Lacertae object B3 2247+381 with the MAGIC telescopes