import java.io.*;
import java.util.*;

public class aplusb_nv_slow {

	BufferedReader br;
	PrintWriter out;
	StringTokenizer st;

	public String nextToken() throws IOException {
		while ((st == null) || (!st.hasMoreTokens()))
			st = new StringTokenizer(br.readLine());
		return st.nextToken();
	}

	public long nextLong() throws IOException {
		return Long.parseLong(nextToken());
	}

	boolean check(String s) {
		for (int i = 1; i < s.length(); i++)
			if (s.charAt(i - 1) == s.charAt(i))
				return false;
		return true;
	}

	public void solve() throws IOException {
		long n = nextLong();
		int ans = 0;
		for (long i = 1; i < n; i++) {
			String s = Long.toString(i);
			String t = Long.toString(n - i);
			if (s.length() == t.length()) {
				if (check(s) && check(t))
					ans++;
			}
		}
		out.println(ans);

	}

	public void run() {
		try {
			br = new BufferedReader(new FileReader("aplusb.in"));
			out = new PrintWriter("aplusb.out");
			solve();
			out.close();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

	public static void main(String[] args) {
		new aplusb_nv_slow().run();
	}
}
