#include <iostream>
#include <string>
#include <sstream>
int main() {
std::string input = "Hello, the wonderful, the awesome and the beautiful world!";
std::string to_find = "the";
int foundCount = 0;
std::stringstream ss( input );
while ( ss.good() ) {
std::string word;
ss >> word;
if ( word == to_find ) {
foundCount++;
}
}
std::cout << "Input: " << input << std::endl;
std::cout << to_find << " found " << foundCount << " times" << std::endl;
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8c3RyaW5nPgojaW5jbHVkZSA8c3N0cmVhbT4KCmludCBtYWluKCkgewoJc3RkOjpzdHJpbmcgaW5wdXQgPSAiSGVsbG8sIHRoZSB3b25kZXJmdWwsIHRoZSBhd2Vzb21lIGFuZCB0aGUgYmVhdXRpZnVsIHdvcmxkISI7CglzdGQ6OnN0cmluZyB0b19maW5kID0gInRoZSI7CglpbnQgZm91bmRDb3VudCA9IDA7CiAgICBzdGQ6OnN0cmluZ3N0cmVhbSBzcyggaW5wdXQgKTsKICAgIHdoaWxlICggc3MuZ29vZCgpICkgewogICAgCXN0ZDo6c3RyaW5nIHdvcmQ7CiAgICAJc3MgPj4gd29yZDsKICAgIAlpZiAoIHdvcmQgPT0gdG9fZmluZCApIHsKICAgIAkJZm91bmRDb3VudCsrOwogICAgCX0KICAgIH0KICAgIHN0ZDo6Y291dCA8PCAiSW5wdXQ6ICIgPDwgaW5wdXQgPDwgc3RkOjplbmRsOwoJc3RkOjpjb3V0IDw8IHRvX2ZpbmQgPDwgIiBmb3VuZCAiIDw8IGZvdW5kQ291bnQgPDwgIiB0aW1lcyIgPDwgc3RkOjplbmRsOwoJcmV0dXJuIDA7Cn0=