Solution for  countingminutes problem