#include #define ALL(v) std::begin(v),std::end(v) using lint=long long; using lubl=long double; template struct span{ using value_type=typename Begin::value_type; Begin begin_; End end_; span(Begin begin__, End end__):begin_(begin__),end_(end__){} auto begin(){return begin_;} auto end(){return end_;} auto begin()const{return begin_;} auto end()const{return end_;} }; int main(){ std::cin.tie(nullptr);std::ios_base::sync_with_stdio(false); std::cout.setf(std::ios_base::fixed);std::cout.precision(15); lint n,m;std::cin>>n>>m; lint X=7*24*60; auto read=[]{ char _;lint d,h,min; std::cin>>d>>h>>_>>min; return ((d-2)*24+h)*60+min; }; std::vector>a(m); for(lint i=0;iocc(X); lint ans=0; for(auto&&p:a){ lint r,l;std::tie(r,l)=p; span sp(occ.begin()+l,occ.begin()+r); if(std::any_of(ALL(sp),[n](lint x){return x==n;}))continue; std::for_each(ALL(sp),[](lint&x){x++;}); ans++; } std::cout<