You forgot to take into consideration leap years... If last 2 digits divides by 4, add an extra day, except for years that ends in 00, like 1500, 1600, 1700, etc... but then, add one if it ends with 000, like 2000, 3000, etc..

Then your math would be right.