A student at a HackerSchool is provided with a schedule of n days, where each day can have up to m hours of lecture classes. The schedule is represented by a binary matrix schedule, where schedule[i][j] = 'T' means there is a lecture at the jth hour of the ith day, and schedule[i][j] = 'O' means there is no lecture at that time.
If the student attends the first lecture at the xth hour and the last lecture at the yth hour on a single day, then they spend (y - x + 1) hours at school on that day. The student is allowed to skip up to k lectures in total over all n days.
Determine the minimum total time in hours the student needs to attend school over all n days, given that they can skip lectures optimally.