#include <iostream>
#include <regex>
using namespace std;
int main() {
std::string pattern("A|D");
std::regex rx(pattern);
std::string s("ABCDEABCABD");
std::ptrdiff_t number_of_matches = std::distance(
std::sregex_iterator(s.begin(), s.end(), rx),
std::sregex_iterator());
std::cout << number_of_matches << std::endl;
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8cmVnZXg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CgppbnQgbWFpbigpIHsKCXN0ZDo6c3RyaW5nIHBhdHRlcm4oIkF8RCIpOwoJc3RkOjpyZWdleCByeChwYXR0ZXJuKTsKCQoJc3RkOjpzdHJpbmcgcygiQUJDREVBQkNBQkQiKTsKCXN0ZDo6cHRyZGlmZl90IG51bWJlcl9vZl9tYXRjaGVzID0gc3RkOjpkaXN0YW5jZSgKICAgIAlzdGQ6OnNyZWdleF9pdGVyYXRvcihzLmJlZ2luKCksIHMuZW5kKCksIHJ4KSwKICAgIAlzdGQ6OnNyZWdleF9pdGVyYXRvcigpKTsKCglzdGQ6OmNvdXQgPDwgbnVtYmVyX29mX21hdGNoZXMgPDwgc3RkOjplbmRsOwoJcmV0dXJuIDA7Cn0=