Distance = speed x time
in upstream = R - S
In downstream = R + S
R is the speed of river water
S is the speed of boat in still water
D=(R+S)4
D=(S-R)5
Since Distance is same in both case
So, (3+S)4=(S-3)5
4S+12=5S-15
S=15+12=27
So, speed = 27 km/h