Just click see inside and backpack the first two blocks after the 'When green flag clicked' block. You can verify that it actually works by clicking 'See inside' and adding or removing a costume from the sprite. This works by using the fact that if you put a number and only a number (call it 'n') into the 'change costume to' block, it selects the n-th costume, and it also uses the fact that putting a zero in there selects the last costume. It then just reads out the costume number and puts it into the '_costume_count' variable.
This is just a really small trick that i needed for a project, and when i found it i decided to share it because i thought that maybe someone else needed it, so don't expect too much from it. I came up with the method myself, altough i was put on the right track by this forum thread: https://scratch.mit.edu/discuss/topic/105122/ By the way, this was the first time i tried to use a thumbnail in a project. How do you think turned out?