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

public class greedy_bm_60 {
	FastScanner in;
	PrintWriter out;

	int[] c;
	boolean[] isNextWord;
	int ans;
	
	int getAns(int x) {
		int cur = 0;
		int res = 1;
		isNextWord[0] = true;
		for (int i = 0; i < c.length; i++) {
			if (cur * 10L + c[i] > x) {
				res++;
				cur = c[i];
				isNextWord[i] = true;
			} else {
				cur = cur * 10 + c[i];
			}
		}
		ans = res;
		return res;
	}

	void changeAns(int pos, int x) {
		while (!isNextWord[pos])
			pos--;
		int need = 1;
		if (pos != 0) {
			need++;
			pos--;
			while (!isNextWord[pos])
				pos--;
		}
		int cur = 0;
		for (int i = pos; i < c.length; i++) {
			if (cur * 10L + c[i] > x) {
				cur = c[i];
				if (isNextWord[i]) {
					need--;
					if (need == 0)
						return;
				} else {
					ans++;
				}
				isNextWord[i] = true;
			} else {
				if (isNextWord[i] && i != pos) {
					ans--;
					isNextWord[i] = false;
				}
				cur = cur * 10 + c[i];
			}
		}
	}
	
	void solve() {
		String s = in.next();
		c = new int[s.length()];
		for (int i = 0; i < s.length(); i++)
			c[i] = s.charAt(i) - '0';
		int m = in.nextInt();
		int x = in.nextInt();
		isNextWord = new boolean[s.length()];
		out.println(getAns(x));
		for (int i = 0; i < m; i++) {
			int pos = in.nextInt() - 1; 
			c[pos] = in.nextInt();
			changeAns(pos, x);
			out.println(ans);
		}
	}

	void run() {
		try {
			in = new FastScanner(new File("greedy.in"));
			out = new PrintWriter(new File("greedy.out"));

			solve();

			out.close();
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		}
	}

	void runIO() {

		in = new FastScanner(System.in);
		out = new PrintWriter(System.out);

		solve();

		out.close();
	}

	class FastScanner {
		BufferedReader br;
		StringTokenizer st;

		public FastScanner(File f) {
			try {
				br = new BufferedReader(new FileReader(f));
			} catch (FileNotFoundException e) {
				e.printStackTrace();
			}
		}

		public FastScanner(InputStream f) {
			br = new BufferedReader(new InputStreamReader(f));
		}

		String next() {
			while (st == null || !st.hasMoreTokens()) {
				String s = null;
				try {
					s = br.readLine();
				} catch (IOException e) {
					e.printStackTrace();
				}
				if (s == null)
					return null;
				st = new StringTokenizer(s);
			}
			return st.nextToken();
		}

		boolean hasMoreTokens() {
			while (st == null || !st.hasMoreTokens()) {
				String s = null;
				try {
					s = br.readLine();
				} catch (IOException e) {
					e.printStackTrace();
				}
				if (s == null)
					return false;
				st = new StringTokenizer(s);
			}
			return true;
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}
	}

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