#include <iostream>
#include <queue>
#include <iomanip>
using namespace std;
class customer
{
public:
bool operator > (const customer & cu) const;
int hh,mm,ss,last;
};
bool customer::operator > (const customer & cu) const
{
if((hh>cu.hh)||(hh==cu.hh&&mm>cu.mm)||(mm==cu.mm&&ss>cu.ss))
{
return true;
}
else
{
return false;
}
}
class window
{
public:
enum{b_hh=8,b_mm=0,b_ss=0,e_hh=17,e_mm=0,e_ss=0};
window();
bool operator > (const window & win) const;
int doserver(customer &cu);
int hh,mm,ss;
};
bool window::operator > (const window & win) const
{
if((hh>win.hh)||(hh==win.hh&&mm>win.mm)||(hh==win.hh&&mm==win.mm&&ss>win.ss))
{
return true;
}
else
{
return false;
}
}
window::window()
{
hh=b_hh;
mm=b_mm;
ss=b_ss;
}
int window::doserver(customer &cu)
{
if((cu.hh>e_hh)||(cu.hh==e_hh&&cu.mm>e_mm)||(cu.hh==e_hh&&cu.mm==e_mm&&cu.ss>e_ss)) return -1;
int wt=((hh-cu.hh)*3600+(mm-cu.mm)*60+(ss-cu.ss));
if(wt>0)
{
ss+=cu.last*60;
mm+=ss/60;ss%=60;
hh+=mm/60;mm%=60;
return wt;
}
else
{
ss=cu.ss+cu.last*60;
mm=cu.mm+ss/60;ss%=60;
hh=cu.hh+mm/60;mm%=60;
return 0;
}
}
class A
{
public:
void init();
void run();
private:
priority_queue<window,vector<window>,greater<window> > wq;
priority_queue<customer,vector<customer>,greater<customer> > cq;
int winnum,cusnum;
};
void A::init()
{
int i;
window win;
customer cus;
cin>>cusnum>>winnum;
for(i=0;i<cusnum;i++)
{
cin>>(cus.hh);getchar();
cin>>(cus.mm);getchar();
cin>>(cus.ss);getchar();
cin>>(cus.last);
cq.push(cus);
}
for(i=0;i<winnum;i++)
{
wq.push(win);
}
}
void A::run()
{
customer cu;
window win;
int ct,count=0,total=0;
double ftotal;
while(!cq.empty())
{
cu=cq.top();cq.pop();
win=wq.top();wq.pop();
ct=win.doserver(cu);
if(ct>=0)
{
total+=ct;
count++;
}
wq.push(win);
}
ftotal = total/count/60.0;
cout<<fixed<<setprecision(1)<<ftotal;
}
int main()
{
// freopen("test.in","r",stdin);
A *a=new A;
a->init();
a->run();
return 0;
}