when is safe sex period

How do you do a perfect clycle calculation for yourself both when you take postinor 2 in between and when you don't . ( safe time to have sex)