Lewis Hamilton snuck into the third part of qualifying in Russia after a red flag brought about by Sebastian Vettel had put his hopes in doubt.