#include<cstdio>
#include<iostream>
#include<cstring>
#include<queue>
using namespace std;
const int M=9999,INF=999999999;
int deep[M];
int tot,cnt;
int r,c,u;int p[100][100];
char a[100][100],b;
int e[1999][1999];
int bfs(int s,int t){
queue< int > d;
memset(deep,-1,sizeof(deep));
deep[s]=0;
d.push(s);
while(!d.empty()){
int x=d.front();
d.pop();
for(int i=1;i<=tot;i++){
if(e[x][i]&&deep[i]==-1){
deep[i]=deep[x]+1;
d.push(i);
}
}
}
return deep[t]!=-1;
}
int dfs(int s,int t,int f){
if(s==t) return f;
for(int i=1;i<=tot;i++){
if(e[s][i]&&deep[s]+1==deep[i]){
int d=dfs(i,t,min(e[s][i],f));
if(d>0){
e[s][i]-=d;
e[i][s]+=d;
return d;
}
}
}
return 0;
}
int maxflow(int s,int t){
int flow=0;
while(bfs(s,t)){
while(1)
{
int d=dfs(s,t,INF);
if(d==0)break;
flow+=d;
}
}
return flow;
}
int cinn()
{
cin>>r>>c>>u;
for(int i=1;i<=r;i++)
for(int j=1;j<=c;j++){
cin>>a[i][j];
if(a[i][j]!='0'){
tot++;p[i][j]=tot;
e[tot][tot+1]=a[i][j]-48;tot++;
}
}
for(int i=1;i<=r;i++)
for(int j=1;j<=c;j++){
cin>>b;
if(b=='L'){
cnt++;e[0][p[i][j]]=1;
}
if(a[i][j]>'0')
{
for(int k=1;k<=r;k++)
for(int q=1;q<=c;q++)
{
if(a[k][q]>'0'&&(i!=k||j!=q))
{
if((k-i)*(k-i)+(q-j)*(q-j)<=u*u)
e[p[i][j]+1][p[k][q]]=INF;
}
}
}
}
}
int goutu(){
for(int i=1;i<=r;i++)
for(int j=1;j<=c;j++){
if(a[i][j]>'0')
{
if(i-u<1||i>r-u||j-u<1||j>c-u)
e[p[i][j]+1][tot]=INF;
}
}
return 0;
}
int main(){
cinn();
tot++;
goutu();
int d=maxflow(0,tot);
printf("%d",cnt-d);
return 0;
}