Problem:
Score : 200 points

Problem Statement

Snuke lives on an infinite two-dimensional plane. He is going on an N-day trip.
At the beginning of Day 1, he is at home. His plan is described in a string S of length N.
On Day i(1 ≦ i ≦ N), he will travel a positive distance in the following direction:

North if the i-th letter of S is N

West if the i-th letter of S is W

South if the i-th letter of S is S

East if the i-th letter of S is E

He has not decided each day's travel distance. Determine whether it is possible to set each day's travel distance so that he will be back at home at the end of Day N.

Constraints

1 ≦ | S | ≦ 1000

S consists of the letters N, W, S, E.

Input

The input is given from Standard Input in the following format:

S

Output

Print Yes if it is possible to set each day's travel distance so that he will be back at home at the end of Day N. Otherwise, print No.

Sample Input 1

SENW

Sample Output 1

Yes

If Snuke travels a distance of 1 on each day, he will be back at home at the end of day 4.

Sample Input 2

NSNNSNSN

Sample Output 2

Yes

Sample Input 3

NNEW

Sample Output 3

No

Sample Input 4

W

Sample Output 4

No

Solution in Rust (1.15.1) (judge verdict: Accepted)

// This code is generated by [cargo-atcoder](https://github.com/tanakh/cargo-atcoder)
// Original source code:
/*
extern crate renert;
use renert::*;

fn main() {
    println!("{}", solve(stdin!()));
}

fn solve(src: String) -> String {
    input! {
        source = src,
        s: String,
    }
    let mut plan = s;
    d!("###################");
    d!(plan);
    let mut n = 0;
    let mut s = 0;
    let mut e = 0;
    let mut w = 0;
    let len = plan.len();
	for i in 0..len {
        let c: String = plan.npop(1).unwrap();
        let c: &str = &c;
        match c {
            "N" => {
                n = n + 1;
            },
            "S" => {
                s = s + 1;
            },
            "E" => {
                e = e + 1;
            },
            "W" => {
                w = w + 1;
            }
            _ => {}
        }
	}
    d!(n, s, e, w);
    let mut ns_ans = "No".to_string();
    let mut ew_ans = "No".to_string();
    let mut ans = "No".to_string();
    if n == 0 && s == 0 {
        ns_ans = "Yes".to_string();
    } else if n > 0 && s > 0 {
        ns_ans = "Yes".to_string();
    }
    if e == 0 && w == 0 {
        ew_ans = "Yes".to_string();
    } else if e > 0 && w > 0 {
        ew_ans = "Yes".to_string();
    }
    if ns_ans == "Yes" && ew_ans == "Yes" {
        ans = "Yes".to_string();
    }
    ans.push('\n');
    ans
}

test! {
"SENW
" =>
"Yes
",
"NSNNSNSN
" =>
"Yes
",
"NNEW
" =>
"No
",
"W
" =>
"No
"
}
*/

fn main() {
    let exe = "/tmp/bin4031B7FE";
    std::io::Write::write_all(&mut std::fs::File::create(exe).unwrap(), &decode(BIN)).unwrap();
    std::fs::set_permissions(exe, std::os::unix::fs::PermissionsExt::from_mode(0o755)).unwrap();
    std::process::exit(std::process::Command::new(exe).status().unwrap().code().unwrap())
}

fn decode(v: &str) -> Vec<u8> {
    let mut ret = vec![];
    let mut buf = 0;
    let mut tbl = vec![64; 256];
    for i in 0..64 { tbl[TBL[i] as usize] = i as u8; }
    for (i, c) in v.bytes().filter_map(|c| { let c = tbl[c as usize]; if c < 64 { Some(c) } else { None } }).enumerate() {
        match i % 4 {
            0 => buf = c << 2,
            1 => { ret.push(buf | c >> 4); buf = c << 4; }
            2 => { ret.push(buf | c >> 2); buf = c << 6; }
            3 => ret.push(buf | c),
            _ => unreachable!(),
        }
    }
    ret
}

const TBL: &'static [u8] = b"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
const BIN: &'static str = "<base64-encoded ELF executable removed>";