Cost basis for the sale of a second home

hello everyone,

 

I sold a second home in 2022 after almost five years of owning it. I got the original mortgage in 2018 and refinanced in 2022. Can I include the various closing costs of these two mortgages in the cost basis that I am deducting from the gross proceeds (1099-S) of the property? 

 

Thanks for the info.