Let us assume number of $5 bills = x.
Number of $20 is three times as many twenties as fives bills.
and number of $20 bills = 3x.
Total amount of all bills = $585.
$5 times number of x bills + $20 times number of 3x bills = $585.
5x + 20*3x = 585.
5x + 60x = 585.
Adding 5x+6x, we get 65x.
65x = 585.
Dividing both sides by 65.
65x/65 = 585/65.
x=9.
Therefore, number of $5 bills = 9.
Number of $20 is three times of number of $5 bills, that is 3*9 = 27.
Therefore, 9 are number of $5 bills and 27 are number of $20 bills.