Greg and Sarah will split their apples, so 18 apples / 2 = <<18/2=9>>9 apples per child.
Susan has 2 * 9 apples = <<2*9=18>>18 apples.
Mark has 18 apples - 5 apples = <<18-5=13>>13 apples.
Combined the children have 9 apples + 9 apples + 18 apples + 13 apples = <<9+9+18+13=49>>49 apples.
Mom will have 49 apples - 40 apples = <<49-40=9>>9 apples left over.
#### 9