Martin Grass, the former CEO of Rite Aid ( RAD), has agreed to plead guilty to two counts of conspiracy, which would lead to fines of around $3.5 million and an eight-year prison sentence.

The deal Grass reached means he'll plead guilty to one count of conspiracy to defraud Rite Aid and the company's shareholders and one count of conspiracy to obstruct justice. The remaining charges against him will be dropped, and he'll cooperate with authorities going forward.

His trial had been scheduled to start in a few days, and he was facing 35 criminal counts related to the drugstore chain's accounting scandal before the plea arrangement was reached.

Earlier this month, Frank Bergonzi, Rite Aid's former financial chief, pleaded guilty to a conspiracy charge and said he would help prosecutors.

Former vice chairman Franklin Brown is also facing charges, as is another executive, Eric Sorkin. The charges stemmed from a restatement of Rite Aid's 1998 and 1999 income, in which the company overstated its earnings by $1.6 billion.

Shares of Rite Aid were up 20 cents to $4.63 in recent New York Stock Exchange trading.