It is necessary to create a calculation algorithm in one formula

Good afternoon Is there a way to do this kind of calculation below in 1 formula? If possible, please tell me how to do this calculation. In this case, the number of overdue tasks for each month should be shown. According to these formulas, more than 60 days in total is considered overdue. That is, the task must be completed within 60 days

Algorithm for calculating repetitions

  1. If the task is not completed, consider the date today - minus the number of days for pauses and minus the start date.

  2. If the task is closed, the status is ready - STP approval date - minus the number of days for pauses and minus the start date.

I hope I explained it clearly, if you need clarification, please write