You've spotted something good by separating out "real" and "exist"!
The philosopher Willard Van Orman Quine suggested that the second of these questions is decided by our use of classical, first order predicate logic. When we ask what it means for an entity to exist, what it means for us to be "Ontologically Committed" to something, we look at what, in logically rigorous terms, we mean, and we ask about what objects our theory needs to include in order to make sense of the idea of a Variable having the Values it needs to make the sentences we say true.
Let's take an example in number theory: "there is a prime number p such that p+2 and p+6 are also prime numbers". It's clear to us what this means (for example, p=5 and p=11 are known solutions), even if we don't intuitively know how many things there might be that satisfy it!
In order to make sense of it, we seem to think about p as a variable ranging over a domain of things - the natural numbers. For Quine, this is sufficient to say that we are Ontologically Committed to (at least some) natural numbers as being in our class of stuff in the world. Now, does this mean we have to think of numbers as any particular stuff? Not in itself - we might want to think of numbers as just bundles of patterns realized by physical systems, or component elements of human formal symbol practices, or spatiotemporally isolated abstract entities on a higher plane of existence - but we still want to find some way to validate our talk of prime numbers existing, and that's what it means to be Ontologically Committed.
This does prompt a question of how we flesh out our explanation of whether mathematical objects "really" exist. What lies at the bottom of this chain of ontological reasoning, if there is even such a bottom? This is the question of Realism, and this field is much more complex than a simple answer here might start to pick at, but to keep going with Quine's approach, Quine was a Scientific Realist - the stuff that is real is whatever is needed to ground our best scientific practice.
Interestingly, seeing Mathematics as a science in its own right, he concluded that there was no question of needing to reduce mathematical objects to anything else - if it's central to our good scientific practice, then if you want to know what mathematical objects really exist, you just need to ask a mathematician!