Number of long rulers sold is 2 parts out of 3 parts total of long rulers, and number of short rulers sold are 5 parts out of 6 parts total of short rulers.
Since the number of short and long rulers sold is the same, we will use a common unit to represent them. A convenient number would be 10u, since 10 is the lcm of the 2 parts of long and 5 parts of short ruler sold.
Long rulers sold = 10u, which is 2/3.
Therefore total of long rulers is 15u, i.e 3/3.
Short rulers sold = 10u, which is 5/6.
There total of short rulers = 12u, i.e 6/6.
15u + 12u = 540
u = 540/27 = 20
Long rulers left = 5u
Short ruler left = 2u
Total rulers left = 7u = 140#