from copy import deepcopy H,W,K=map(int,input().split()) def calc(H,W,K): if K==1: return 1 SET=set() ANS=0 A=[[0]*W for i in range(H)] for i in range(K**(H*W)): x=i for j in range(H): for k in range(W): A[j][k]=x%K x//=K B=deepcopy(A) for i in range(H): B[i]=tuple(B[i]) flag=1 for i in range(H): if tuple(B[i:]+B[:i]) in SET: flag=0 break for i in range(W): for j in range(H): B[j]=B[j][1:]+B[j][:1] if tuple(B) in SET: flag=0 break if flag==1: ANS+=1 for i in range(W): for j in range(H): B[j]=B[j][1:]+B[j][:1] for j in range(H): SET.add(tuple(B[i:]+B[:i])) return ANS if K==1: print(1) elif K==2: print(calc(H,W,K)-2) else: print(calc(H,W,3)-3*calc(H,W,2)+3*calc(H,W,1))