#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;
}