#include <iostream>
#include <string>
#include <set>
int count(std::string input)
{
static const std::set<char> delimeters{' ', '.', ',', ':', '-'};
static const std::set<char>::iterator _end = delimeters.end();
int word_count{};
int state{};
for (std::string::iterator it=input.begin(); it!=input.end(); ++it)
if (delimeters.find(*it) == _end) state++;
else
{
word_count+= state > 0 ? (state+1)%2 : 0;
state = 0;
}
word_count+= state > 0 ? (state+1)%2 : 0;
return word_count;
}
int main() {
// your code goes here
std::cout << count("- one, two,three . four :five");
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8c3RyaW5nPgojaW5jbHVkZSA8c2V0PgoKaW50IGNvdW50KHN0ZDo6c3RyaW5nIGlucHV0KQp7CglzdGF0aWMgY29uc3Qgc3RkOjpzZXQ8Y2hhcj4gZGVsaW1ldGVyc3snICcsICcuJywgJywnLCAnOicsICctJ307CglzdGF0aWMgY29uc3Qgc3RkOjpzZXQ8Y2hhcj46Oml0ZXJhdG9yIF9lbmQgPSBkZWxpbWV0ZXJzLmVuZCgpOwoJCglpbnQgd29yZF9jb3VudHt9OwoJaW50IHN0YXRle307Cglmb3IgKHN0ZDo6c3RyaW5nOjppdGVyYXRvciBpdD1pbnB1dC5iZWdpbigpOyBpdCE9aW5wdXQuZW5kKCk7ICsraXQpCgkJaWYgKGRlbGltZXRlcnMuZmluZCgqaXQpID09IF9lbmQpIHN0YXRlKys7CgkJZWxzZQoJCXsKCQkJd29yZF9jb3VudCs9IHN0YXRlID4gMCA/IChzdGF0ZSsxKSUyIDogMDsKCQkJc3RhdGUgPSAwOwoJCX0KCQkKCXdvcmRfY291bnQrPSBzdGF0ZSA+IDAgPyAoc3RhdGUrMSklMiA6IDA7CgkKCXJldHVybiB3b3JkX2NvdW50Owp9CgoKaW50IG1haW4oKSB7CgkvLyB5b3VyIGNvZGUgZ29lcyBoZXJlCgkKCXN0ZDo6Y291dCA8PCBjb3VudCgiLSBvbmUsIHR3byx0aHJlZSAuIGZvdXIgOmZpdmUiKTsKCQoJcmV0dXJuIDA7Cn0=