#include <iostream>
#include <numeric>
#include <vector>

int main()
{
    std::vector<int> kidHeights = { 1, 3, 6, 5, 6, 4, 2, 3 };

    int numberOfKidsThatCanSeeToTheRight =
        std::accumulate(kidHeights.rbegin(), kidHeights.rend(), 0,
                        [](int curKidCount, int curHeight) {

                            // assuming positive heights
                            static int curMaxHeight = 0;

                            if (curHeight > curMaxHeight) {
                                ++ curKidCount;
                                curMaxHeight = curHeight;
                            }

                            return curKidCount;
                        });

    std::cout << numberOfKidsThatCanSeeToTheRight << std::endl;
}