How is peak margin calculated?

For F&O, the margin required is SPAN + Exposure.
For stocks, the margin required is VAR + ELM.