That's going to be very hard because the end tags for the markup could be outside the 400 characters.
I recommend not using rich text. If you must use Rich Text, you could just warn the users and have them manually reduce it until it's <400 characters and then enable a submit button. That's probably the best way for Rich Text - just have the user do it. :)