Ethan had some red beans and green beans. The ratio of the number of red beans to the number of green beans was 5: 8. After Fandi took away 4 red beans and 4 green beans, the new ratio became 1: 2. Find the total number of beans he had at the end.

Let the number of red beans initially be 5x, and the number of green beans be 8x.

After Fandi took away 4 red beans and 4 green beans, the number of red beans became 5x - 4, and the number of green beans became 8x - 4.
After Fandi took away 4 red beans and 4 green beans, the ratio of the number of red beans to the number of green beans became (5x - 4): (8x - 4) = 1/2.
2(5x - 4) = 1(8x - 4).
10x - 8 = 8x - 4.
10x - 8x = -4 + 8.
2x = 4.
x = 4/2.
x = 2.
The total number of beans Ethan had at the end is 5x + 8x = 13x = 13(2) = <<5*2+8*2=26>>26. Answer: \boxed{26}.