#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:300000000")
#pragma warning(disable : 4800)
using namespace std;
const double pi = 3.1415926535897932384626433832795;
template <class T>
T abs(const T &a) {
  return a >= 0 ? a : -a;
};
template <class T>
T sqr(const T &x) {
  return x * x;
}
string a, b;
vector<bool> bb;
int k;
const int mod = int(1e9 + 7);
int sum;
int s1[1000], s2[1000];
int main() {
  cin >> a >> b >> k;
  bb.resize(int((a).size()));
  for (int i = 0; i < (int((a).size())); i++) {
    if (a == b) bb[i] = true;
    a = a.substr(1) + a[0];
  }
  s1[0] = 1;
  sum = 1;
  for (int _ = 0; _ < (k); _++) {
    for (int i = 0; i < (int((a).size())); i++) {
      s2[i] = (sum - s1[i] + mod) % mod;
    }
    sum = 0;
    for (int i = 0; i < (int((a).size())); i++) sum = (sum + s2[i]) % mod;
    memcpy(s1, s2, sizeof(s1));
  }
  int ans = 0;
  for (int i = 0; i < (int((a).size())); i++)
    if (bb[i]) ans = (ans + s1[i]) % mod;
  cout << ans;
}
