Hi,
You will need to review the guidance on statutory residence and take the test, to determine your residence status.
Please also have a look at the guidance at:
RDRM11700 - Residence: The SRT: Days spent in the UK: Contents which coves days spent in the UK.
We cannot advise how you calculate the number of days worked in the UK, as we can only provide general information / guidance in this forum.
For an answer to a more detailed question of this nature, you would need to contact our self assesment helpline on 0300 200 3310, contact our webchat facility at
https://www.gov.uk/contact-hmrc or seek professional advice.
Thank you.