Reverse engineering of metacognition