SAN FRANCISCO -- Matt Duffy was busy doing math in his head.
It was the bottom of the ninth inning in Sunday's series finale against Miami, and Giants catcher Andrew Susac had just hit a one-out single. So Duffy started started counting and found out he was five batters away from reaching the plate.
"I knew if I did come up, it would be bases loaded, two outs in a tie game," Duffy said.
The Giants shortstop was right. And he delivered.
Duffy came through with an RBI single to left field to give the Giants a 3-2 win and collect his first career walk-off hit. His game-winner caused the Giants to spill out of the dugout and mob Duffy near second base. Joe Panik even apologized afterward for punching Duffy repeatedly in the ribs.
"Honestly, I didn't feel a thing," Duffy said with a smile.
Duffy made his first start of the season at shortstop in place of Brandon Crawford, who began the game on the bench along with fellow regulars Buster Posey and Angel Pagan. Duffy also got some credit from manager Bruce Bochy for setting up San Francisco's first run by moving Nori Aoki to third with a sixth-inning ground ball.
Still, the 24-year-old was 0-for-4 entering his final at-bat.
"Turning your day around and getting the team a win is a good feeling," Duffy said.
Duffy said Aoki's six-pitch walk with the bases loaded, which scored Joaquin Arias to tie the game, also helped Duffy get a good bead on Marlins reliever Steve Cishek. Considering the Giants threw out Christian Yelich at home in the top half of the inning before sending seven men to the plate for the game-winning rally, it was a team effort.
"We're going to just put a good at-bat together as long as possible, until the game is over," Duffy said. "That's what the guys were able to do today to even get me up in that situation. Comebacks like that don't happen with one guy."
Alex Espinoza is a contributor to MLB.com. This story was not subject to the approval of Major League Baseball or its clubs.