In 1852, aged only 11, he entered the Imperial School of Jurisprudence in Saint Petersburg, where he was a class mate of Pyotr Ilyich Tchaikovsky, who was his exact contemporary and became a lifelong friend. The founder, duke Peter of Oldenburg, and the director, Alexander Yazykov, took him under their personal wings. He graduated with distinction in 1859. His work was encouraged by Turgenev and Fet.
While he was polite and courteous in the company of women, he became a witty storyteller in the company of men. His conversation was "imbued with such wit and clothed in such attractive form that for the sake of this alone one forgot the frivolity of the contents".