Except for the diagonal piece we just have to count squares along the perimeter. Let's focus on the diagonal.
It's the diagonal of right triangle that's 6 wide and 8 tall, so the diagonal is 10, (6,8,10) being twice (3,4,5), the first Pythagorean triple on the list.
d² = 6² + 8² = 10²
d = 10
The rest is counting. We already know the height is 8. The top is 8 too, the bottom is 8 plus the 6 we already counted, so 14.
P = 8 + 8 + 14 + 10 = 40
Answer: 40