ORCHARD PARK, N.Y. — The Buffalo Bills took the first step in restocking their quarterback position by agreeing to a two-year contract with A.J. McCarron.

The 27-year-old spent the past four seasons backing up Andy Dalton in Cincinnati after being selected by the Bengals in the fifth round of the 2014 draft.

McCarron's signing on Wednesday came a few hours after the NFL's free-agency period opened, and five days after Buffalo traded three-year starter Tyrod Taylor to Cleveland. The trade left 2017 fifth-round pick Nathan Peterman as the only quarterback on Buffalo's roster.

General manager Brandon Beane said he intended to add a veteran quarterback this off-season to provide experience.

With two picks in each of the first three rounds of the draft, Buffalo also is expected to target one of the highly touted quarterback prospects.

McCarron was a two-time national champion at Alabama but appeared in just 11 games in Cincinnati, mostly in mop-up duties. McCarron did start the final three games of the 2015 season and led the Bengals to the playoffs after Dalton broke his thumb.

Against Pittsburgh in the wild-card playoff game, McCarron had the Bengals in position to win their first playoff game since the 1990 season. Jeremy Hill however lost a fumble, and penalties on Vontaze Burfict and Adam "Pacman" Jones set up the Steelers for a winning field goal in the final seconds.

Though he missed his rookie season because of a sore passing shoulder, McCarron was allowed to become an unrestricted free agent after an independent arbitrator ruling last month. McCarron was also nearly traded to Cleveland last season, but the deal fell through after the Browns failed to submit the paperwork on time.