Ok, got it. The title of the question illuminates it better than the question itself :)
You need to first find out how many times each FK appears:
select count(*) as GroupAmount from t1 group by foreign_id
After that, you should group them to get the number of times each item is displayed as above. This will lead to:
select GroupAmount, count(*) GroupAmountTimes from ( select count(foreign_id) as GroupAmount from t1 group by foreign_id ) as SubQuery group by GroupAmount
See in action here
source share