Simple C++ solution for 46