import java.util.*; import java.io.*; public class Main { static int[][] dp; static int[][] contests; public static void main(String[] args) throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String[] first = br.readLine().split(" ", 2); int n = Integer.parseInt(first[0]); int p = Integer.parseInt(first[1]); dp = new int[n + 1][p + 1]; contests = new int[n + 1][3]; for (int i = 1; i <= n; i++) { String[] line = br.readLine().split(" ", 3); for (int j = 0; j < 3; j++) { contests[i][j] = Integer.parseInt(line[j]); } Arrays.fill(dp[i], Integer.MAX_VALUE); } System.out.println(dfw(n, p) / (double) n); } static int dfw(int idx, int count) { if (count < 0) { return Integer.MAX_VALUE / 2; } if (idx <= 0) { return 0; } if (dp[idx][count] != Integer.MAX_VALUE) { return dp[idx][count]; } for (int i = 0; i < 3; i++) { dp[idx][count] = Math.min(dp[idx][count], dfw(idx - 1, count - i) + contests[idx][i]); } dp[idx][count] = Math.min(dp[idx][count], dfw(idx - 1, count - 3) + 1); return dp[idx][count]; } }