#include <bits/stdc++.h>
using namespace std;
using p = pair<int, int>;
#define IOS \
ios::sync_with_stdio(false); \
cin.tie(nullptr); \
cout.tie(nullptr);
#define int long long
const int INF = 1e18;
const int mod = 998244353;
void solve()
{
int n, m, k;
int ansfinal = 0;
cin >> n >> m >> k;
vector<string> ans(n);
for (auto &p : ans)
cin >> p;
if (m >= k)
for (int i = 0; i < n; i++)
{
int tmp = 0;
for (int l = 0; l < k; l++)
{
tmp += (ans[i][l] == '*');
}
if (!tmp)
ansfinal++;
for (int j = k; j < m; j++)
{
tmp += (ans[i][j] == '*') - (ans[i][j - k] == '*');
if (!tmp)
ansfinal++;
}
}
if (n >= k)
for (int j = 0; j < m; j++)
{
int tmp = 0;
for (int l = 0; l < k; l++)
{
tmp += (ans[l][j] == '*');
}
if (!tmp)
ansfinal++;
for (int i = k; i < n; i++)
{
tmp += (ans[i][j] == '*') - (ans[i - k][j] == '*');
if (!tmp)
ansfinal++;
}
}
if (k == 1)
ansfinal /= 2;
cout << ansfinal << endl;
return;
}
signed main()
{
IOS;
int t;
// cin >> t;
t = 1;
while (t--)
{
solve();
}
system("pause");
return 0;
}
#include <bits/stdc++.h>
using namespace std;
using p = pair<int, int>;
#define IOS \
ios::sync_with_stdio(false); \
cin.tie(nullptr); \
cout.tie(nullptr);
#define int long long
const int INF = 1e18;
const int mod = 998244353;
const int maxn = 3e5 + 1;
vector<int> connects[maxn];
int indegree[maxn];
void add_edge(int u, int v)
{
connects[u].push_back(v);
indegree[v]++;
return;
}
int dp[maxn][26];
void solve()
{
int n, m;
cin >> n >> m;
string s;
cin >> s;
for (int i = 1; i <= m; i++)
{
int u, v;
cin >> u >> v;
add_edge(u, v);
}
int cnt = 0;
queue<int> q;
for (int i = 0; i < n; i++)
{
dp[i + 1][s[i] - 'a']++;
if (!indegree[i + 1])
q.push(i + 1);
}
int finalans = -1;
while (!q.empty())
{
int pos = q.front();
q.pop();
cnt++;
if (connects[pos].empty())
{
for (int i = 0; i <= 25; i++)
{
finalans = max(finalans, dp[pos][i]);
}
continue;
}
for (auto v : connects[pos])
{
for (int i = 0; i <= 25; i++)
{
dp[v][i] = max(dp[v][i], dp[pos][i] + ((s[v - 1] - 'a') == i));
}
indegree[v]--;
if (!indegree[v])
q.push(v);
}
}
if (cnt != n)
{
cout << -1 << endl;
}
else
{
cout << finalans << endl;
}
return;
}
signed main()
{
IOS;
int t;
// cin >> t;
t = 1;
while (t--)
{
solve();
}
system("pause");
return 0;
}
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define IOS \
ios::sync_with_stdio(false); \
cin.tie(0); \
cout.tie(0);
int quickpow(int a, int b, int mod)
{
int e = 1;
while (b)
{
if (b & 1)
(e *= a) %= mod;
(a *= a) %= mod;
b >>= 1;
}
return e;
}
int quickinv(int a, int mod)
{
return quickpow(a, mod - 2, mod);
}
int a, b, x, p;
void Exgcd(int a, int b, int &x, int &y)
{
if (!b)
{
x = 1, y = 0;
return;
}
Exgcd(b, a % b, y, x);
y -= (a / b) * x;
return;
}
int inv(int a, int mod)
{
int x, y;
Exgcd(a, mod, x, y);
return (x + mod) % mod;
}
int CRT(int a, int b)
{
int N = p * (p - 1);
return (a * p % N * inv(p, p - 1) % N + b * (p - 1) % N * inv(p - 1, p) % N) % N;
}
void solve()
{
cin >> a >> b >> p >> x;
int ans = 0;
for (int q = 0; q <= p - 2; q++)
{
int t = (b % p * quickinv(quickpow(a, q, p), p)) % p;
int crt = CRT(q, t);
if (x >= crt)
ans += (x - crt) / (p * (p - 1)) + 1;
}
cout << ans << endl;
return;
}
signed main()
{
IOS;
int t;
t = 1;
while (t--)
solve();
return 0;
}