class Ideone {
public static void main
(String[] args
) { System.
out.
println(countVirgulas
("30,60,90")); }
static int countVirgulas
(String parametro
) { int count = 0;
for (int i = 0; i < parametro.length(); i++) {
if (parametro.charAt(i) == ',') {
count++;
}
}
return count;
}
}
Y2xhc3MgSWRlb25lIHsKCXB1YmxpYyBzdGF0aWMgdm9pZCBtYWluIChTdHJpbmdbXSBhcmdzKSB7CgkJU3lzdGVtLm91dC5wcmludGxuKGNvdW50VmlyZ3VsYXMoIjMwLDYwLDkwIikpOwoJfQogICAgc3RhdGljIGludCBjb3VudFZpcmd1bGFzKFN0cmluZyBwYXJhbWV0cm8pIHsKICAgICAgICBpbnQgY291bnQgPSAwOwogICAgICAgIGZvciAoaW50IGkgPSAwOyBpIDwgcGFyYW1ldHJvLmxlbmd0aCgpOyBpKyspIHsKICAgICAgICAgICAgaWYgKHBhcmFtZXRyby5jaGFyQXQoaSkgPT0gJywnKSB7CiAgICAgICAgICAgICAgICBjb3VudCsrOwogICAgICAgICAgICB9CiAgICAgICAgfQogICAgICAgIHJldHVybiBjb3VudDsKICAgIH0KfQ==