#include <bits/stdc++.h>
using namespace std;
const int INF = 1 << 30;
int main() {
  ios::sync_with_stdio(false);
  long long int MOD = 1000000007LL;
  string start, end;
  int k;
  while (cin >> start >> end >> k) {
    const int N = static_cast<int>(start.size());
    vector<long long int> dp(N, 0LL);
    dp[0] = 1LL;
    for (int i = 0; i < k; ++i) {
      long long int sum = accumulate(dp.begin(), dp.end(), 0LL) % MOD;
      for (int j = 0; j < N; ++j) {
        dp[j] = sum - dp[j] + MOD;
        dp[j] %= MOD;
      }
    }
    long long int ans = 0LL;
    for (int i = 0; i < N; ++i) {
      if (start.substr(i) + start.substr(0, i) == end) {
        ans += dp[i];
        ans %= MOD;
      }
    }
    cout << ans << endl;
  }
  return 0;
}
