A cube with sides of length 3cm is painted red
and then cut into 3 x 3 x 3 = 27 cubes with sides of length 1cm.
If a denotes the number of small cubes (of 1cm x 1cm x 1cm) that
are not painted at all, b the number painted on one sides, c the
number painted on two sides, and d the number painted on three
sides, determine the value a-b-c+d.
1. **Determine the number of small cubes that are not painted at all ($a$):**
   - The small cubes that are not painted at all are those that are completely inside the larger cube, not touching any face. 
   - For a cube of side length 3 cm, the inner cube that is not painted has side length \(3 - 2 = 1\) cm (since 1 cm on each side is painted).
   - Therefore, there is only \(1 \times 1 \times 1 = 1\) small cube that is not painted at all.
   - Hence, \(a = 1\).

2. **Determine the number of small cubes painted on one side ($b$):**
   - The small cubes painted on one side are those on the faces of the cube but not on the edges or corners.
   - Each face of the cube has \(3 \times 3 = 9\) small cubes.
   - The cubes on the edges of each face (excluding the corners) are \(3 \times 4 = 12\) (since each edge has 3 cubes, and there are 4 edges per face, but each corner is counted twice).
   - Therefore, the number of cubes on each face that are painted on one side is \(9 - 4 = 5\).
   - Since there are 6 faces, the total number of cubes painted on one side is \(6 \times 5 = 30\).
   - Hence, \(b = 6 \times (3-2)^2 = 6 \times 1 = 6\).

3. **Determine the number of small cubes painted on two sides ($c$):**
   - The small cubes painted on two sides are those on the edges of the cube but not on the corners.
   - Each edge of the cube has 3 small cubes, but the two end cubes are corners.
   - Therefore, each edge has \(3 - 2 = 1\) cube painted on two sides.
   - Since there are 12 edges, the total number of cubes painted on two sides is \(12 \times 1 = 12\).
   - Hence, \(c = 12 \times (3-2) = 12\).

4. **Determine the number of small cubes painted on three sides ($d$):**
   - The small cubes painted on three sides are those on the corners of the cube.
   - A cube has 8 corners.
   - Hence, \(d = 8\).

5. **Calculate \(a - b - c + d\):**
   \[
   a - b - c + d = 1 - 6 - 12 + 8 = -9
   \]

The final answer is \(\boxed{-9}\)