The base of an isosceles triangle is one more than twice the length of its legs. The perimeter is 25. Find the length of the legs.