This is the modified code what is the problem in my code

import java.util.*;
public class Main {
public static void TravelRowWise(Character[][] park, int K, int S, int N, int M) {
boolean flag = true;
for (int i = 0; i < park.length ; i++) {
for (int j = 0; j < park[i].length ; j++) {

			if (S < K) {
				flag = false;
				break;
			}
			if (park[i][j] == '.') {
				// . occurs decrease S by 2
				S = S - 2;
				
			} else if (park[i][j] == '*') {
				S = S + 5;
				
			} else if (park[i][j] == '#') {

				break;
			}
			// decrease strength from o to n-1 except last col
			if (j != N - 1) {
				S--;
			}
		}
	}
	if (flag) {
		System.out.println("Yes");
		System.out.println(S);
	} else {
		System.out.println("No");
		System.out.println(S);
	}
}

public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);

	int N = sc.nextInt();
	int M = sc.nextInt();
	int K = sc.nextInt();
	int S = sc.nextInt();
	Character[][] park = new Character[N][M];

	for (int i = 0; i < N; i++) {
		for (int j = 0; j < M; j++) {
			park[i][j] = sc.next().charAt(0);
		}
	}
	TravelRowWise(park, K, S, N, M);

}

}