You have to clear at your first port of entry into the US. So it would be Newark.
Clear passport control or whatever it's called, collect your bags, clear customs, drop your bags off (they should have been checked through when you dropped them off), clear security, and head to the next flight.
I would figure a half hour at the absolute minimum to get to the point where you drop off your bags, it could be a couple hours if lots of flights are coming in at the same time. I don't know if it takes people with non US passports any longer or not.