AUBURN HILLS, Mich. — When he became a free agent last summer, Boban Marjanovic’s first choice was to stay in San Antonio.

So coach Gregg Popovich sat the 7-foot-3 Serbian down for a math lesson.

“He’s such a good kid, at some point I had to work to get him to understand that $21 million was different than $3 million,” Popovich said. “I said, ‘Get your ass out of here. Go. You’ve got to do it.’ But he felt bad.”

Heeding Popovich’s advice, Marjanovic signed a three-year, $21 million deal with Detroit, where he joins a pair of other ex-Spurs in Aron Baynes and Ray McCallum.

Odds are good Marjanovic is poised to become the same kind of cult hero in the Motor City as he was in San Antonio.

Before Monday’s preseason game against the Spurs — his first as a Piston at the Palace of Auburn Hills — Marjanovic paused to take photos with fans gathered courtside, some wearing Spurs jerseys. He dressed but did not play.

“Everybody who has met him has enjoyed him,” Pistons coach Stan Van Gundy said. “What people see obviously first is the size, but he’s genuinely a nice guy.”

The Spurs imported Marjanovic from Europe two summers ago on a modest $1.2 million deal that made him a restricted free agent after one season.

At the time, nobody was sure if Marjanovic would stick in the NBA beyond that.

After a rookie season in which he became one of the most efficient players in the league on a per-minute basis, Marjanovic entered an over-heated free agency market last summer. Popovich knew then there was little hope of bringing him back.

“We knew he was gone,” Popovich said. “It happens to every team. You lose a guy because you have to pay people and you can’t pay them all.”

After some reluctance at leaving his first NBA home, Marjanovic is settling in with Detroit.

“My first wish was to stay,” Marjanovic said. “But this is good now. I think I made a good decision.”

Pulling for Anthony: The decision to pursue Marjanovic was not an easy one for the Pistons, either. To clear salary cap space, Detroit had to waive center Joel Anthony, who is now one of five players vying for the Spurs’ final roster spot.

“I hope he gets it,” Van Gundy said. “Joel is one of the best professionals in this game. He’s always ready to play. Those guys, to me, are invaluable. We need more people like Joel Anthony in this league. Everybody here is pulling for him.”

A rugged defender and rebounder, the 34-year-old Anthony appeared in 68 games combined with Detroit over the past two seasons.

Popovich said Anthony’s experience gives him a chance to make the team.

“He’s really, really solid,” Popovich said.

Free basketball: The Spurs will host their annual open scrimmage Oct. 18 at the AT&T Center.

The event, which is free to the public, will begin at 7 p.m.