Officials have begun counting votes in Afghanistan after an election marred by violence and electoral irregularities.