There are many ways to do this.
Here's the simplest
Go to the subjects table. Perform a find that specifies a subject and whatever data represents "failed". The number of records found will be your answer.
Other methods can be used that employ the ExecuteSQL function or a relationship that matches only to a specified subject and Pass/fail status can also be used.
A summary report on a layout based on Subjects can even list all subjects a single time with the count of failed or passing students in each subject.
Thanks a lot for your reply, but can I save the result of find , i.e, saving the number of record to use later?
With a script yes, it can store the result of Get ( FoundCount ) into a field or variable.
But I suggest describing what you want in more detail as that might result in a better approach.
Please note that performing a find was just one of several methods that I listed.