You can query the amount of replies in your first query (I named the result column "ReplyCount" here):
$query = 'SELECT *,
(SELECT Count(replyThreadID) FROM replies WHERE replyThreadID = t.threadID) AS ReplyCount
FROM threads AS t
JOIN profile AS p ON t.threadBy = p.username
WHERE t.threadTopic="'.$topic.'"
ORDER BY lastActive DESC LIMIT 3';
And then simply read that column as any other.
SQL-Fiddle:
http://sqlfiddle.com/#!9/6bd0f/2[
^]
By the way, I would suggest you explicitly specify the columns you want to select, instead of using SELECT *