#include <iomanip>
#include <iostream>
#include <string>

unsigned count_occurrences(const std::string& source, char terminal, const std::string& allowed)
{
    unsigned count = 0;
    std::size_t offset = 0;
    while ((offset = source.find(terminal, offset)) != std::string::npos)
    {
        std::size_t next_off = source.find_first_not_of(allowed, offset+1);
        if (next_off != std::string::npos && source[next_off] == terminal)
            ++count;

        offset = next_off; 
    }

    return count;
}

std::string quoted(const std::string& s)
{
    return '"' + s + '"';
}

int main()
{
    std::string test_cases [] = 
    { 
        "+---", 
        "---+ +---", 
        "+--- ---+", 
        "---+", 
        "+--+--+", 
        "+-+", 
        "+--- +", 
        "+ -+" 
    };

    std::cout << std::left;
    for (auto& test : test_cases)
        std::cout << std::setw(15) << quoted(test) << count_occurrences(test, '+', "-") << '\n';
}