Calculate rem

Calculate rem
Source: Codementor