using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication2
{
    class Program
    {
        static void Main(string[] args)
        {
            int month = 0;
            int g = 0;
            string a = Console.ReadLine();
            Int64 N = Convert.ToInt64(a.Split(' ')[0]);
            Int64 M = Convert.ToInt64(a.Split(' ')[1]);
            Int64 K = Convert.ToInt64(a.Split(' ')[2]);
            Int64[] y = new Int64[K];
            Int64[] x = new Int64[K];
            string[] b = new string[K];
            for (int i = 0; i < K; i++)
                b[i] = Console.ReadLine();

            for (int i = 0; i < K; i++)
            {
                y[i] = Convert.ToInt64(b[i].Split(' ')[0]);
                x[i] = Convert.ToInt64(b[i].Split(' ')[1]);
            }
            if (K < 10)
            {
                Random rnd = new Random();
                month = rnd.Next(1, 4);
            }
            else
                if (K < 30)
                {
                    Random rnd = new Random();
                    month = rnd.Next(1, 10);
                }
                else
                    if (K < 100)
                    {
                        Random rnd = new Random();
                        month = rnd.Next(10, 32);
                    }
                    else
                        if (K < 100000)
                        {
                            Random rnd = new Random();
                            month = rnd.Next(100, 1001);
                        }
            Console.WriteLine(month);
            Console.ReadLine();
                
        }
    }
}