Sherlock and Joan investigate the murder of a mathematician whose walls are painted with a complex formula. A colleague of Sherlock’s reveals the formula is a nearly unsolvable problem, and directs them to a professor, Tayna, who had written about the formula. Tanya points them to a suspect, but he's been murdered. Sherlock realizes the second victim was under surveillance and tracks down the man responsible. He tells Sherlock the value of the completed formula - a skeleton key to bypass any encryption - and directs them back at Tanya, but she provides a video recording of her alibi. Sherlock confronts Tanya with evidence that she manipulated the footage because she already solved the problem and killed the two victims because they were getting close. Meanwhile, Joan meets with the son of the patient she lost during surgery and he asks her for money.