Each piece is x inches long. If she cut 5 inches from x, then it's now x-5 inches long.
This is equal to 3 inches (given) so equate the two expressions and isolate x
x-5 = 3
x-5+5 = 3+5
x = 8
Each piece is 8 inches long. There are 3 pieces. Therefore the original ribbon was 24 inches long (8*3 = 24).