This is dependent on creating a query to count distinct records, in the example, this query is called qry. To update your table, you can then say:
UPDATE MyTable
SET MyTable.P =
DCount("*","qry","s<=" & [MyTable].[s] & " and r=""" & [MyTable].[r] & """");
There is one more point to note, this is qry:
SELECT DISTINCT z.r, z.s
FROM MyTable AS z;
MyTable is aliased.