#include <iostream>
#include <vector>                                
#include <algorithm>                             
#include <iterator>
#include <cctype>

int main()
{
    std::string words;
    std::vector<std::string> dWords;  
    while(std::cin >> words)
    {
    	// remove punctuation
    	words.erase(std::remove_if(words.begin(), words.end(), [](char ch) 
    					{ return ::ispunct(static_cast<int>(ch)); }), words.end());
        dWords.push_back(words);      
    }
    
    // partition D from non-D words
    auto iter = std::partition(dWords.begin(), dWords.end(), [](const std::string& s) 
                                         { return toupper(s[0]) == 'D'; });
                                         
	// output results                                         
    std::cout << "The number of words starting with D: " << std::distance(dWords.begin(), iter) << "\n";
    std::cout << "Here are the words:\n";
    std::copy(dWords.begin(), iter, std::ostream_iterator<std::string>(std::cout, " "));
    
    std::cout << "\n\nThe number of words not starting with D: " << std::distance(iter, dWords.end()) << "\n";
    std::cout << "Here are the words:\n";
    std::copy(iter, dWords.end(), std::ostream_iterator<std::string>(std::cout, " "));
}
