Simple C++ solution for 39