#include <bits/stdc++.h>
using namespace std;
int n, m, k;
string a, b;
int DP[1001][1001][11];
int calc(int i, int j, int k) {
  if (i >= n) return 0;
  if (j >= m) return 0;
  if (k <= 0) return 0;
  if (DP[i][j][k] != -1) return DP[i][j][k];
  int c = 0, x = i, y = j;
  while (a[x] == b[y] && x < n && y < m) {
    x++;
    y++;
    c++;
  }
  int z = max(c + calc(x, y, k - 1), max(calc(i + 1, j, k), calc(i, j + 1, k)));
  return DP[i][j][k] = z;
}
int main() {
  memset(DP, -1, sizeof DP);
  cin >> n >> m >> k;
  cin >> a >> b;
  cout << calc(0, 0, k) << endl;
  return 0;
}
