This question is terribly worded I think. Basically it wants you to find the length of the input string and let this length become the new string. Keep following this process until the length of the string and string are the same.
import java.io.PrintWriter; import java.util.Scanner; /** * * @author Sanchit M. Bhatnagar * @see http://uhunt.felix-halim.net/id/74004 * */ public class P11687 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); PrintWriter out = new PrintWriter(System.out); while (sc.hasNext()) { String input = sc.next(); if (input.equals("END")) break; out.println(solve(input)); } out.close(); sc.close(); } private static int solve(String input) { int count = 1; int len = input.length(); if ((len + "").equals(input)) return count; else return count + solve(len + ""); } }