Counting painted sides of cubic shapes Sandbox
Many of us have seen math problems where a shape made of unit cubes is dipped in paint, and the answer is the number of painted sides. We'll generalize that problem in this challenge.
Input
A 3-dimensional matrix of 0s and 1s.
Output
A non-negative integer
Challenge
Given a n by m by k matrix of 0s and 1s, we can view the matrix as a 3D shape by considering a n by m by k rectangular prism broken up into n * m * k unit cubes, and the unit cubes  corresponding to the 0 values in the matrix are removed.
For example, the matrix [[[1,0],[0,0]],[[1,1],[0,1]]] represents the shape

Given such a shape, the code-golf challenge is to output the number of painted sides on the shape if the whole shape is dunked in paint.
Test Cases
[[[1,1,1],[1,1,1],[1,1,1]],[[1,1,1],[1,0,1],[1,1,1]],[[1,1,1],[1,1,1],[1,1,1]]] -&gt; 54

[[[1,0],[0,0]],[[1,1],[0,1]]] -&gt; 18

[[[1]],[[0]],[[1]]] -&gt; 12

[[[1,1,1,1,1,1],[1,1,1,1,1,1],[1,1,1,1,1,1],[1,1,1,1,1,1]],[[1,1,1,1,1,1],[1,0,0,0,0,1],[1,0,0,0,0,1],[1,1,1,1,1,1]],[[1,1,1,1,1,1],[1,0,0,0,0,1],[1,0,0,0,0,1],[1,1,1,1,1,1]],[[1,1,1,1,1,1],[1,0,1,1,0,1],[1,0,1,1,0,1],[1,1,1,1,1,1]],[[1,1,1,1,1,1],[1,0,1,1,0,1],[1,0,0,1,0,1],[1,1,1,1,1,1]],[[1,1,1,1,1,1],[1,1,1,1,1,1],[1,1,1,1,1,1],[1,1,1,1,1,1]]] -&gt; 168

[[[0,0,0],[0,1,0],[0,0,0]],[[0,1,0],[1,0,1],[0,1,0]],[[0,0,0],[0,1,0],[0,0,0]]] -&gt; 30

[[[1,1,1,1,1],[1,1,1,1,1],[1,1,1,1,1],[1,1,1,1,1],[1,1,1,1,1]],[[1,1,1,1,1],[1,0,0,0,1],[1,0,0,0,1],[1,0,0,0,1],[1,1,1,1,1]],[[1,1,1,1,1],[1,0,0,0,1],[1,0,1,0,1],[1,0,0,0,1],[1,1,1,1,1]],[[1,1,1,1,1],[1,0,0,0,1],[1,0,0,0,1],[1,0,0,0,1],[1,1,1,1,1]],[[1,1,1,1,1],[1,1,1,1,1],[1,1,1,1,1],[1,1,1,1,1],[1,1,1,1,1]]] -&gt; 150

[[[1,1,0,1,1],[1,1,0,1,1],[1,1,0,1,1]],[[1,1,0,1,1],[1,1,0,1,1],[1,1,0,1,1]],[[1,1,0,1,1],[1,1,0,1,1],[1,1,0,1,1]],[[1,1,0,1,1],[1,1,0,1,1],[1,1,0,1,1]]] -&gt; 104

[[[0,1,1],[1,1,1],[1,1,1]],[[1,1,1],[1,0,1],[1,1,1]],[[1,1,1],[1,1,1],[1,1,1]]] -&gt; 54
APL (Dyalog Unicode), 55 48 bytes

≢⍸↑2≠/¨⊢∘g\3⍴⊂2=2(g⊣(⌈∧⊢)/,)⍣6⍣≡(1,g←⍉⍤2⍉∘⌽)⍣6~⎕

Try it online!
-7 bytes thanks to @ngn.
Improvements:

2 3 1⍉ → ⍉⍤2⍉: Replace &quot;cycle the axes once&quot; with &quot;swap 1st and 3rd axes, then 2nd and 3rd&quot;
{⍵(g⍵)(g g⍵)} → ⊢∘g\3⍴⊂: A scan that ignores the left arg and applies g to the right arg, so it works like this:

3⍴⊂x gives (x x x)
⊢∘g\3⍴⊂x gives (x)(x ⊢∘g x)(x ⊢∘g x ⊢∘g x)
which is the same as (x)(g x)(g g x) because:
  x ⊢∘g x
→ x ⊢ g x
→ x ⊢ (g x)
→ g x


APL (Dyalog Unicode), 55 bytes

{≢⍸↑2≠/¨⍵(g⍵)(g g⍵)}2=2(g⊣(⌈∧⊢)/,)⍣6⍣≡(1,g←2 3 1⍉⌽)⍣6~⎕

Try it online!
A full program that takes a 3D array. Uses the flood fill already used here. Another key idea is g←2 3 1⍉⌽, which effectively cycles through all six sides when applied with ⍣6 (repeat six times).
How it works
{≢⍸↑2≠/¨⍵(g⍵)(g g⍵)}2=2(g⊣(⌈∧⊢)/,)⍣6⍣≡(1,g←2 3 1⍉⌽)⍣6~⎕

~⎕                ⍝ Logical negation of the input
(1,g←2 3 1⍉⌽)⍣6   ⍝ Pad with a layer of ones on all six sides
2(g⊣(⌈∧⊢)/,)⍣6⍣≡  ⍝ Flood fill from the outside, changing 1s to 2s:
2(        ,)      ⍝   Prepend 2 on the last axis
   ⊣(⌈∧⊢)/        ⍝   Pairwise lcm(max(x,y),y) over the last axis
                  ⍝   Effectively, propagate 2 to an adjacent 1 on the right
  g               ⍝   Cycle the orientation once
            ⍣6⍣≡  ⍝   Repeat 6 times until the flood fill is complete
2=                ⍝ Map 2s to 1s, and anything else to 0s
{⍵(g⍵)(g g⍵)}     ⍝ Construct 3 arrays so that each axis becomes the last axis
2≠/¨              ⍝ Extract faces (where 0 and 1 are adjacent) for each array
≢⍸↑               ⍝ Count ones in all arrays