Dating is a bit of a gamble. You could miss out on finding “The One” if you settle down too soon, but wait too long and you risk ending up alone. So how many people should you date before you commit? Mathematics has an answer.

The optimal stopping problem, also known as “the secretary problem” or the marriage problem, was first popularized in the 1950s. It’s about decision-making under uncertainty: you want to know when you’ve found the right choice and when to stop looking. In short, you want to maximize the probability of choosing the best person, while reducing the risk or rejecting that person and they go elsewhere.

The ideal strategy—knowing the optimal time to stop—is thought to have been first solved by American mathematician Merrill Flood, and first appeared in print by British statistician Dennis Lindley, in 1961. According to the theory, to find the best person to marry, or hire, you have to pass over the first 37% of people.

As Mark Colyvan, a professor of philosophy at the University of Sydney who advises against marrying the first person you date (pdf), explains:

It can be shown mathematically that the optimal strategy, for a large applicant pool (i.e. when n is large) is to pass over the first n/e (where e is the transcendental number from elementary calculus—the base of the natural logarithm, approximately 2.718) applicants and accept the next applicant who’s better than all those previously seen. This gives a probability of finding the best secretary (mate) at 1⁄e or approximately 0.37.

Hannah Fry, a lecturer in the Mathematics of Cities at University College London, has applied the mathematical solution to modern dating.

On Tinder and other apps like Bumble, Happn, and Hinge, daters can either swipe left to reject or right to accept different profiles, but the choice can be overwhelming. To apply the optimal stopping problem, set aside 100 profiles on Tinder, reject the first 37%, and then pick the next best person better than the previous profiles.

There are some drawbacks to this method. For one, the original secretary problem assumes “all or nothing”—dating is far messier. And as Fry points out in her TEDx talk, there are some risks to relying on this solution to the optimal stopping theory: your perfect partner *could* appear during your first 37%. That said, at least it’s better than nothing.

“You’re far more likely to get the best person for you if you actively seek dates rather than waiting to be contacted,” Xand van Tulleken writes for the BBC after applying Fry’s lessons in real-life. “The mathematicians can prove it’s better not to be a wallflower.”