# [Retina], <s>41</s> 38 bytes

    .*$
    $*
    !&`(.)+(?=.*¶(?<-1>.)+(?(1)¶)$)

[Try it online!]

Takes the string and count on separate lines. The first two lines are used to convert the count from decimal to unary, so if unary input is acceptable then the byte count would be reduced to <s>34</s> 31. Edit: Saved 3 bytes thanks to @FryAmTheEggman. Or, if you prefer, a 48-byte version that handles newlines in the string, although that does produce confusing output:

    .*$
    $*
    !&`(\S|\s)+(?=[\S\s]*¶(?<-1>.)+(?(1)$.)$)

[Retina]: https://github.com/m-ender/retina
[Try it online!]: https://tio.run/nexus/retina#@6@npcKlosWlqJagoaeprWFvq6d1aJuGvY2uoR2Yr2GoeWibporm//@OIc7ujo7u7kAqhMsEAA "Retina – TIO Nexus"