Detection of very-high-energy gamma rays from the most distant and gravitationally lensed blazar QSO B0218+357 using the MAGIC telescope system