#include <stdio.h>
#include <memory.h>
#include <math.h>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <map>
#define I scanf
#define OL puts
#define O printf
#define F(a,b,c) for(a=b;a<c;a++)
#define FF(a,b) for(a=0;a<b;a++)
#define FG(a,b) for(a=b-1;a>=0;a--)
#define LEN 1010
#define MAX (1<<30)+1
#define V vector<int>
using namespace std;
struct Customer{
int comeTime;
int serveTime;
Customer(int c,int s):comeTime(c),serveTime(s){
}
};
bool cmp(Customer a,Customer b){
return a.comeTime<b.comeTime;
}
int processTime(int H,int M,int S){
return H*3600+M*60+S;
}
int windowEnd[1000];//每个窗口的结束时间
int main(){
// freopen("1017.txt","r",stdin);
int N,M,i,j,hh,mm,ss,p;
I("%d %d",&N,&M);
int startTime=processTime(8,0,0);
int endTime=processTime(17,0,0);
vector<Customer> C;
FF(i,M) windowEnd[i]=startTime; //初始化每个窗口的开始时间
while(N--){
I("%d:%d:%d %d",&hh,&mm,&ss,&p);
int thisTime=processTime(hh,mm,ss);
if(thisTime>endTime) continue;
p*=60;
p=min(p,3600); //处理排队超时
C.push_back(Customer(thisTime,p));
}
sort(C.begin(),C.end(),cmp);
int wait=0;
//对于每一个顾客进行处理
FF(i,C.size()){
//选择一个最早结束的
int minTime=MAX,mI;
FF(j,M) {
if(windowEnd[j]<minTime){
minTime=windowEnd[j];
mI=j;
}
}
if(windowEnd[mI]>C[i].comeTime){ //顾客来早了,需要等待
wait+=windowEnd[mI]-C[i].comeTime;
windowEnd[mI]+=C[i].serveTime;
}else{ //顾客不用等待
windowEnd[mI]=C[i].comeTime+C[i].serveTime;
}
}
O("%.1f\n",wait/60.0/C.size());
return 0;
}