import java.io.*; import java.util.*; public class Main { static int k; static HashSet boxes = new HashSet<>(); public static void main(String[] args) throws Exception { Scanner sc = new Scanner(); Box.height = sc.nextInt(); Box.width = sc.nextInt(); k = sc.nextInt(); makeBox(0, new int[Box.height * Box.width]); System.out.println(boxes.size()); } static void makeBox(int idx, int[] values) { if (idx == Box.height * Box.width) { Box b = new Box(values); if (b.getType() != k) { return; } boxes.add(b); return; } for (int i = 0; i < k; i++) { values[idx] = i; makeBox(idx + 1, values); } } static class Box { static int height; static int width; int[][] colors; int hash; int[] type = new int[3]; public Box(int[] arr) { colors = new int[height][width]; for (int i = 0; i < arr.length; i++) { colors[i / width][i % width] = arr[i]; hash += pow(100, arr[i]); type[arr[i]]++; } } static int pow(int x, int p) { if (p == 0) { return 1; } else { return x * pow(x, p - 1); } } public int hashCode() { return hash; } public int getType() { int count = 0; for (int x : type) { if (x > 0) { count++; } } return count; } public boolean equals(Object o) { Box b = (Box)o; for (int i = 0; i < height; i++) { for (int j = 0; j < width; j++) { if (equals(b, i, j)) { return true; } } } return false; } private boolean equals(Box b, int r, int c) { for (int i = 0; i < height; i++) { for (int j = 0; j < width; j++) { if (colors[(i + r) % height][(j + c) % width] != b.colors[i][j]) { return false; } } } return true; } } } class Scanner { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(""); public Scanner() throws Exception { } public int nextInt() throws Exception { return Integer.parseInt(next()); } public long nextLong() throws Exception { return Long.parseLong(next()); } public double nextDouble() throws Exception { return Double.parseDouble(next()); } public String next() throws Exception { if (!st.hasMoreTokens()) { st = new StringTokenizer(br.readLine()); } return st.nextToken(); } }