You can use a system of equations.
x=group 1
y=group 2
x+y=28
2x+4=y
Isolate the variable in equation 1.
y=-x+28
Substitute it into equation 2.
-x+28=2x+4
Solve.
-3x=-24
x=8
Substitute it into one of the equations for y.
-x+28=y
-8+28=y
y=20
There are 8 students in one group and 20 students in the other.
Hope this helps!