You only have 60 days as the grace period after your opt, which is same as F-1. So, it your opt ends 7/31, that means you need to count Aug for 31 days and Spt. for 29 days. You will have 2 days for illegal status.