#include #include #include #include using namespace std; int main() { int c; cin >> c; int total = 0; map m; while (cin >> c) { if ( m.find(c) != m.end() ) { total += m[c]; m[c] = -1; } else { m[c] = -1; } vector del; for (auto key : m) { if (key.first < c) del.push_back(key.first); else m[key.first]++; } for (auto d : del) m.erase(d); } cout << total << endl; return 0; }