The short answer is some function, f(a,b,c). Normally f is the exclusive or function. See below
It's easy. The fourth drive contains "parity". That means if you read bit number N from all four drives you get four bits. The first three bits are your data, the fourth bit is either a 1 or a 0 that was written so that the total number of 1s is even. So if your three data bits are 111 to fourth is 1 if your data is 110 the fourth is 0. There is always either 0, 2 or 4 one bits in each group of four.
Now lets say a drive has failed. Say it's the second drive and you get 1X00. It is pretty easy to figure out the X=1 Same of the first drive had failed you read X100 and know that the failed drive must have had a 1.
I'm sure they do more than this. Likely computer a check sum on each sector at least.
Actually the system is more economical of there are five drives but then the more drives the greater chance on might fail. The bigger high end RAID boxes have hot spare drives that get automatically swapped in when a failure is detected. That way once a week or so the user replace the drives with red lights and then those become the new spares. We have a RAID system here at work that is a cabinet about 6 feet tall with something like a zillion disk drives. With that many drives on average you see many failures but the spares just kick in, until you run out.