It works fine when I enter a positive number, but then there is an unwanted incrementation when the input is negative. How to satisfy the last condition? I even used the letters 'a' & 'b' as depicted in the question. Thanks in advance!

package com.codegym.task.task06.task0606;
import java.io.*;
/*
Even and odd digits
*/
public class Solution {
public static int even;
public static int odd;
public static void main(String[] args) throws IOException {
BufferedReader x = new BufferedReader(new InputStreamReader(System.in));
String N = x.readLine();
int n = Integer.parseInt(N);
int rem, a=0, b=0;
if(n<0){
n = n*(-1);
System.out.println(n);
}
for(int j=0; j<N.length(); j++){
rem = n%10;
n = n/10;
if(n%2==0){
even += 1;
}
else if(n==0){
even += 1;
}
else
odd += 1;
System.out.println(even+" "+odd);
}
a = even; b = odd;
System.out.println("Even: "+a+" Odd: "+b);
//write your code here
}
}