The following will give you a new table containing unique combinations of RelatedTo and RulesID. From there you can use a For...Next loop to count the rows.
Dim matches As New DataTable("matches")
matches.Columns.Add("ID")
matches.Columns.Add("RelatesTo")
matches.Columns.Add("RulesID")
matches.Rows.Add("ID10", "ID1", "Rule1")
matches.Rows.Add("ID11", "ID1", "Rule1")
matches.Rows.Add("ID12", "ID1", "Rule2")
matches.Rows.Add("ID13", "ID1", "Rule3")
matches.Rows.Add("ID14", "ID2", "Rule1")
matches.Rows.Add("ID15", "ID2", "Rule3")
matches.Rows.Add("ID16", "ID3", "Rule2")
matches.Rows.Add("ID17", "ID3", "Rule3")
matches.Rows.Add("ID18", "ID4", "Rule3")
Dim unique As DataTable = matches.DefaultView.ToTable("unique", True, New String() {"RelatesTo", "RulesID"})