#if DEBUG
using System.Reflection;
using System.Threading.Tasks;
#endif

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

namespace _307d
{
	class Program
	{
		static string _inputFilename = "input.txt";
		static string _outputFilename = "output.txt";
#if DEBUG
        static bool _useFileInput = false;
#else
		static bool _useFileInput = false;
#endif

		static void Main(string[] args)
		{
			StreamWriter file = null;
			if (_useFileInput)
			{
				Console.SetIn(File.OpenText(_inputFilename));
				file = new StreamWriter(_outputFilename);
				Console.SetOut(file);
			}

#if DEBUG
			if (!_useFileInput)
			{
				Console.SetIn(getInput());
			}
#endif

			try
			{
				solution();
			}
			finally
			{
				if (_useFileInput)
				{
					file.Close();
				}
			}
		}

		static void solution()
		{
			#region SOLUTION
			var d = readLongArray();
			var n = d[0];
			var k = d[1];
			var l = (int)d[2];
			var m = d[3];

			if (l == 0)
			{
				Console.WriteLine(0);
				return;
			}

			for (int i = l; i < 64; i++)
			{
				if (((1L << i) & k) != 0)
				{
					Console.WriteLine(0);
					return;
				}
			}

			var fim = new Matrix { _11 = 0, _12 = 1, _21 = 1, _22 = 1 };
			//fim.Print();
			var sq = pow(fim, n - 1, m);
			//sq.Print();

			var fn0 = (sq._21 + sq._22) % m;
			var fn1 = (sq._11 + sq._12) % m;
			var fr = (fn0 + fn1) % m;

			//var fi = new int[n + 1];
			//fi[0] = 1;
			//fi[1] = 1;
			//for (int i = 2; i < n + 1; i++)
			//{
			//	fi[i] = fi[i - 1] + fi[i - 2];
			//}

			var nc = pow(2, n, m);
			nc -= fr;
			if (nc < 0)
			{
				nc += m;
			}
			//nc *= ((n - 1) % m);
			nc %= m;

			var res = 1L;
			for (int i = 0; i < l; i++)
			{
				if (((1L << i) & k) != 0)
				{
					res *= nc;
					res %= m;
				}
				else
				{
					res *= fr;
					res %= m;
				}
			}

			Console.WriteLine(res);

			//var n = readInt();
			//var m = readInt();

			//var a = readIntArray();
			//var b = readIntArray();
			#endregion
		}

		class Matrix
		{
			public long _11;
			public long _12;
			public long _21;
			public long _22;

			public void Mult(Matrix x, long mod)
			{
				var __11 = (_11 * x._11) % mod + (_12 * x._21) % mod;
				var __12 = (_11 * x._21) % mod + (_12 * x._22) % mod;
				var __21 = (_21 * x._11) % mod + (_22 * x._21) % mod;
				var __22 = (_21 * x._21) % mod + (_22 * x._22) % mod;

				_11 = __11 % mod;
				_12 = __12 % mod;
				_21 = __21 % mod;
				_22 = __22 % mod;
			}

			public void Square(long mod)
			{
				Mult(this, mod);
			}

			public void Print()
			{
				Console.WriteLine("{0} {1}", _11, _12);
				Console.WriteLine("{0} {1}", _21, _22);
				Console.WriteLine();
			}
		}

		static Matrix pow(Matrix x, long p, long mod)
		{
			//p %= mod;

			var res = new Matrix() { _11 = 1, _22 = 1 };
			var a = new Matrix() { _11 = x._11, _12 = x._12, _21 = x._21, _22 = x._22 };
			while (true)
			{
				if (p % 2 == 1)
				{
					res.Mult(a, mod);
					p--;
				}

				if (p == 0)
				{
					break;
				}

				p /= 2;
				a.Square(mod);
			}

			return res;
		}

		static long pow(long x, long p, long mod)
		{
			x %= mod;
			//p %= mod;

			var res = 1L;
			var a = x;
			while (true)
			{
				if (p % 2 == 1)
				{
					res *= a;
					res %= mod;
					p--;
				}

				if (p == 0)
				{
					break;
				}

				p /= 2;
				a *= a;
				a %= mod;
			}

			return res;
		}

		static int readInt()
		{
			return int.Parse(Console.ReadLine());
		}

		static long readLong()
		{
			return long.Parse(Console.ReadLine());
		}

		static int[] readIntArray()
		{
			return Console.ReadLine().Split(' ').Where(i => !string.IsNullOrEmpty(i)).Select(i => int.Parse(i)).ToArray();
		}

		static long[] readLongArray()
		{
			return Console.ReadLine().Split(' ').Where(i => !string.IsNullOrEmpty(i)).Select(i => long.Parse(i)).ToArray();
		}

#if DEBUG
		static StreamReader getInput()
		{
			var resName = Assembly.GetCallingAssembly().GetManifestResourceNames()[0];
			var resource = Assembly.GetCallingAssembly().GetManifestResourceStream(resName);

			return new StreamReader(resource);
		}
#endif
	}
}


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

namespace ConsoleApp1
{
	class Program
	{
		static void Main(string[] args)
		{
			var st = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
			var height = st[0];
			var width = st[1];
			var field = new List<string>(height);
			for(var i =0; i < height; i++)
			{
				field.Add(Console.ReadLine());
			}
			var r = 0;
			var c = 0;
			var sum = field[r][c] == '*' ? 1:0;
			while(r!= height -1 || c != width - 1)
			{
				var rightWithStrawberry = c + 1 < width && field[r][c+1] == '*';
				var downWithStrawberry = r + 1 < height && field[r+1][c] == '*';
				if (rightWithStrawberry)
				{
					c++;
					sum++;
					continue;
				}
				if (downWithStrawberry)
				{
					r++;
					sum++;
					continue;
				}
				if (c + 1 < width) c++;
				else r++;
			}
			Console.WriteLine(sum);
		}
	}
}