RT
//rng_58 bless me
#include<bits/stdc++.h>
using namespace std;
//define:
#define REP(i,n) for(int i = 0; i < n; i++)
//const:
const int MAXN = 2010;
//something:
char a[MAXN][MAXN];
int N,M;
int s1,s2;
int s3,s4;
int ans = 0;
bool vis[MAXN][MAXN];
const int dx[] = {0,0,1,-1};
const int dy[] = {1,-1,0,0};
bool in(int x,int y) {
return x >= 0 && y >= 0 && x < N && y < M;
}
struct node {
int x,y;
int l,r;
node() {}
node(int X,int Y,int L,int R) {
x = X; y = Y; l = L; r = R;
}
};
void bfs() {
queue <node> q;
q.push(node(s1,s2,0,0));
while(!q.empty()) {
node f = q.front();
q.pop();
int x = f.x,y = f.y;
int l = f.l,r = f.r;
//cout << "x:" << x << " y:" << y << " l:" << l << " r:" << r << endl;
if(a[x][y] != '.' || l > s3 || r > s4) {
continue;
}
a[x][y] = '+';
ans++;
REP(d,4) {
int nx = x + dx[d];
int ny = y + dy[d];
if(!in(nx,ny)) {
continue;
}
if(a[nx][ny] == '*') {
continue;
}
int nr = r,nl = l;
if(d == 0) {
nr++;
}
if(d == 1) {
nl++;
}
q.push(node(nx,ny,nl,nr));
}
}
}
//input:
void scan() {
cin >> N >> M;
cin >> s1 >> s2;
s1--; s2--;
cin >> s3 >> s4;
REP(i,N) {
cin >> a[i];
}
}
//output
void print() {
REP(i,N) {
REP(j,M) {
cout << a[i][j];
}
cout << endl;
}
cout << ans << endl;
}
//run:
void solve() {
bfs();
}
//times:
void Times(int T) {
while(T--) {
scan();
solve();
print();
}
}
//begin:
int main() {
int T;
T = 1;
//cin >> T;
Times(T);
return 0;
}