USACO 2019 Gold January Problem Shortcut

USACO 2019 Gold January Problem Shortcut
http://www.usaco.org/index.php?page=viewproblem2&cpid=899
Can anyone help me by explaining the example test case, I have no idea why the output is 40.
Thank you