#include <string>
#include <iostream>
#include <map>
#include <algorithm>
using namespace std;
typedef pair<int, int> point;

struct line
{
    int lineid;
    point starting, ending;
    
    bool operator<(const line& other) const
    {
    	return other.lineid < lineid;
    }
    
};
int main(int argc, char* argv[])
{
    typedef map<int, line> mymap;   
    line w,x,y,z;
    w.lineid = 1;
    w.starting = { 5, 1 };
    w.ending = { 5, 100 };
    x.lineid = 2;
    x.starting = { 20, 56 };
    x.ending = { 120, 56 };
    y.lineid = 3;
    y.starting = { 100, 150 };
    y.ending = { 100, 200 };
    z.lineid = 4;
    z.starting = { 330, 50 };
    z.ending = { 330, 150 };

    mymap bin1;
    bin1.insert({ w.lineid, w });
    bin1.insert({ x.lineid, x });
    bin1.insert({ y.lineid, y });

    mymap bin2;
    bin2.insert({ x.lineid, x });
    bin2.insert({ y.lineid, y });
    bin2.insert({ z.lineid, z });

    mymap out;
    mymap::iterator out_itr(out.begin());
    set_intersection(bin1.begin(), bin1.end(), bin2.begin(), bin2.end(),
                                                 inserter(out, out_itr),
                                                 [] (const std::pair<int, line>& p1, const std::pair<int, line>& p2) { return p1.first != p2.first; } ); 
    cout << "" << out.size();               

        return 0;
    }